{"action":"created","issue":{"url":"https://api.github.com/repos/webpro/versionify/issues/10","labels_url":"https://api.github.com/repos/webpro/versionify/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/webpro/versionify/issues/10/comments","events_url":"https://api.github.com/repos/webpro/versionify/issues/10/events","html_url":"https://github.com/webpro/versionify/issues/10","id":95729259,"number":10,"title":"\"Cannot find module 'package.json'\"; Incorrect reference when requiring package.json for default version","user":{"login":"dhritzkiv","id":1349865,"avatar_url":"https://avatars.githubusercontent.com/u/1349865?v=3","gravatar_id":"","url":"https://api.github.com/users/dhritzkiv","html_url":"https://github.com/dhritzkiv","followers_url":"https://api.github.com/users/dhritzkiv/followers","following_url":"https://api.github.com/users/dhritzkiv/following{/other_user}","gists_url":"https://api.github.com/users/dhritzkiv/gists{/gist_id}","starred_url":"https://api.github.com/users/dhritzkiv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dhritzkiv/subscriptions","organizations_url":"https://api.github.com/users/dhritzkiv/orgs","repos_url":"https://api.github.com/users/dhritzkiv/repos","events_url":"https://api.github.com/users/dhritzkiv/events{/privacy}","received_events_url":"https://api.github.com/users/dhritzkiv/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-17T19:39:19Z","updated_at":"2015-07-18T16:44:10Z","closed_at":"2015-07-18T16:44:10Z","body":"In the latest version (v1.0.5), the behaviour for determing a default `version` value changed to trying to accessing the package.json that's adjacent to the current file being streamed in. This is incorrect, IMO, for a few reasons.\r\n\r\nFor example, many developers have directory structures that resemble this:\r\n\r\n```\r\n|-- /development\r\n    |-- /scripts\r\n        |-- main.js\r\n|-- package.json\r\n```\r\n\r\nSo when the versonify module is passed in, the correct default package.json isn't found (as it is not adjacent), and this error is thrown: `Error: Cannot find module 'package.json'`\r\n\r\nIdeally, the module would first look in the directory adjacent to the file being passed in, and then proceed to the parent directory if not found, until it is found, or until a directory no longer exists or can't be accessed.\r\n\r\nMy workaround has been to explicitly state the `version` value in the module's options."},"comment":{"url":"https://api.github.com/repos/webpro/versionify/issues/comments/122563246","html_url":"https://github.com/webpro/versionify/issues/10#issuecomment-122563246","issue_url":"https://api.github.com/repos/webpro/versionify/issues/10","id":122563246,"user":{"login":"dhritzkiv","id":1349865,"avatar_url":"https://avatars.githubusercontent.com/u/1349865?v=3","gravatar_id":"","url":"https://api.github.com/users/dhritzkiv","html_url":"https://github.com/dhritzkiv","followers_url":"https://api.github.com/users/dhritzkiv/followers","following_url":"https://api.github.com/users/dhritzkiv/following{/other_user}","gists_url":"https://api.github.com/users/dhritzkiv/gists{/gist_id}","starred_url":"https://api.github.com/users/dhritzkiv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dhritzkiv/subscriptions","organizations_url":"https://api.github.com/users/dhritzkiv/orgs","repos_url":"https://api.github.com/users/dhritzkiv/repos","events_url":"https://api.github.com/users/dhritzkiv/events{/privacy}","received_events_url":"https://api.github.com/users/dhritzkiv/received_events","type":"User","site_admin":false},"created_at":"2015-07-18T16:44:10Z","updated_at":"2015-07-18T16:44:10Z","body":"My bad! Seems I misdiagnosed the problem.\r\n\r\nThis bug happened on v1.0.5, where `version` would be calculated for _every_ file being streamed through. One of these files was a bower module (consumed in browserify using debowerify) which didn't happen to have a package.json file (it had a bower.json file, instead).\r\n\r\nI suppose rare events where package.json doesn't exists could be handled better, but it's probably not worth it."}}