{"action":"created","issue":{"url":"https://api.github.com/repos/nodejs/help/issues/377","repository_url":"https://api.github.com/repos/nodejs/help","labels_url":"https://api.github.com/repos/nodejs/help/issues/377/labels{/name}","comments_url":"https://api.github.com/repos/nodejs/help/issues/377/comments","events_url":"https://api.github.com/repos/nodejs/help/issues/377/events","html_url":"https://github.com/nodejs/help/issues/377","id":191394135,"number":377,"title":"Question - How does NPM/Node.js do path resolution in the local node_modules/.bin directory","user":{"login":"ORESoftware","id":11139560,"avatar_url":"https://avatars.githubusercontent.com/u/11139560?v=3","gravatar_id":"","url":"https://api.github.com/users/ORESoftware","html_url":"https://github.com/ORESoftware","followers_url":"https://api.github.com/users/ORESoftware/followers","following_url":"https://api.github.com/users/ORESoftware/following{/other_user}","gists_url":"https://api.github.com/users/ORESoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/ORESoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ORESoftware/subscriptions","organizations_url":"https://api.github.com/users/ORESoftware/orgs","repos_url":"https://api.github.com/users/ORESoftware/repos","events_url":"https://api.github.com/users/ORESoftware/events{/privacy}","received_events_url":"https://api.github.com/users/ORESoftware/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-11-23T22:33:22Z","updated_at":"2016-12-03T03:35:48Z","closed_at":null,"body":"This might be better asked over at NPM, but maybe someone knows \r\n\r\nBeen confused about this for awhile\r\n\r\nI have an executable file (cli/exec.js) in an NPM module called \"foo\" like so:\r\n\r\n    /foo\r\n    --/cli\r\n       exec.js\r\n    --/lib\r\n    package.json\r\n\r\nin package.json, we have:\r\n\r\n      \"name\": \"foo\",\r\n      \"bin\": {\r\n        \"exec-foo\": \"cli/exec.js\"\r\n      }\r\n\r\nwhen this module gets installed, with npm install, node_modules looks like this:\r\n\r\n    --/node_modules\r\n    ---/.bin\r\n        exec-foo\r\n    ---/foo\r\n    ---/lodash\r\n    ---/async\r\n    ---/whatev\r\n\r\n\r\n...What confuses the crap out of me, is how does Node.js do module/dependency resolution with the require function, now that the exec-foo.js file is no longer where it once was in the project, but is now located in `node_modules/.bin`? Is there a simple explanation for this?\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/nodejs/help/issues/comments/264613481","html_url":"https://github.com/nodejs/help/issues/377#issuecomment-264613481","issue_url":"https://api.github.com/repos/nodejs/help/issues/377","id":264613481,"user":{"login":"ORESoftware","id":11139560,"avatar_url":"https://avatars.githubusercontent.com/u/11139560?v=3","gravatar_id":"","url":"https://api.github.com/users/ORESoftware","html_url":"https://github.com/ORESoftware","followers_url":"https://api.github.com/users/ORESoftware/followers","following_url":"https://api.github.com/users/ORESoftware/following{/other_user}","gists_url":"https://api.github.com/users/ORESoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/ORESoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ORESoftware/subscriptions","organizations_url":"https://api.github.com/users/ORESoftware/orgs","repos_url":"https://api.github.com/users/ORESoftware/repos","events_url":"https://api.github.com/users/ORESoftware/events{/privacy}","received_events_url":"https://api.github.com/users/ORESoftware/received_events","type":"User","site_admin":false},"created_at":"2016-12-03T03:35:47Z","updated_at":"2016-12-03T03:35:47Z","body":"I think I got it, symbolic links were the answer right?"}}
{"actor":{"display_login":"ORESoftware"}}