{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/react-native/issues/4968","repository_url":"https://api.github.com/repos/facebook/react-native","labels_url":"https://api.github.com/repos/facebook/react-native/issues/4968/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react-native/issues/4968/comments","events_url":"https://api.github.com/repos/facebook/react-native/issues/4968/events","html_url":"https://github.com/facebook/react-native/issues/4968","id":123828214,"number":4968,"title":"NPM modules get required from /Users/node_modules/ instead of the project directory","user":{"login":"satya164","id":1174278,"avatar_url":"https://avatars.githubusercontent.com/u/1174278?v=3","gravatar_id":"","url":"https://api.github.com/users/satya164","html_url":"https://github.com/satya164","followers_url":"https://api.github.com/users/satya164/followers","following_url":"https://api.github.com/users/satya164/following{/other_user}","gists_url":"https://api.github.com/users/satya164/gists{/gist_id}","starred_url":"https://api.github.com/users/satya164/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/satya164/subscriptions","organizations_url":"https://api.github.com/users/satya164/orgs","repos_url":"https://api.github.com/users/satya164/repos","events_url":"https://api.github.com/users/satya164/events{/privacy}","received_events_url":"https://api.github.com/users/satya164/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/facebook/react-native/labels/Help%20Wanted","name":"Help Wanted","color":"5319e7"},{"url":"https://api.github.com/repos/facebook/react-native/labels/JS","name":"JS","color":"fef2c0"},{"url":"https://api.github.com/repos/facebook/react-native/labels/Tooling","name":"Tooling","color":"0052cc"}],"state":"open","locked":false,"assignee":{"login":"martinbigio","id":535661,"avatar_url":"https://avatars.githubusercontent.com/u/535661?v=3","gravatar_id":"","url":"https://api.github.com/users/martinbigio","html_url":"https://github.com/martinbigio","followers_url":"https://api.github.com/users/martinbigio/followers","following_url":"https://api.github.com/users/martinbigio/following{/other_user}","gists_url":"https://api.github.com/users/martinbigio/gists{/gist_id}","starred_url":"https://api.github.com/users/martinbigio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martinbigio/subscriptions","organizations_url":"https://api.github.com/users/martinbigio/orgs","repos_url":"https://api.github.com/users/martinbigio/repos","events_url":"https://api.github.com/users/martinbigio/events{/privacy}","received_events_url":"https://api.github.com/users/martinbigio/received_events","type":"User","site_admin":false},"assignees":[{"login":"martinbigio","id":535661,"avatar_url":"https://avatars.githubusercontent.com/u/535661?v=3","gravatar_id":"","url":"https://api.github.com/users/martinbigio","html_url":"https://github.com/martinbigio","followers_url":"https://api.github.com/users/martinbigio/followers","following_url":"https://api.github.com/users/martinbigio/following{/other_user}","gists_url":"https://api.github.com/users/martinbigio/gists{/gist_id}","starred_url":"https://api.github.com/users/martinbigio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martinbigio/subscriptions","organizations_url":"https://api.github.com/users/martinbigio/orgs","repos_url":"https://api.github.com/users/martinbigio/repos","events_url":"https://api.github.com/users/martinbigio/events{/privacy}","received_events_url":"https://api.github.com/users/martinbigio/received_events","type":"User","site_admin":false}],"milestone":null,"comments":233,"created_at":"2015-12-24T18:52:47Z","updated_at":"2016-09-01T17:18:33Z","closed_at":null,"body":"There are various issues scattered around the repo related to this issue. Basically what happens is, for some packages, when you try to require `some-module` in a file, for example,\r\n\r\n```js\r\nvar someModule = require('some-module');\r\n```\r\n\r\nIt tries to require the package from home directory instead of the project's `node_modules` directory, and the following wrror appears,\r\n\r\n```sh\r\nUnable to resolve module some-module from /Users/username/projectname/AwesomeProject/index.js: Invalid directory /Users/node_modules/some-module\r\n```\r\n\r\nCurrently, the workarounds seem to be,\r\n\r\n- Delete the `node_modules` folder - `rm -rf node_modules && npm install`\r\n- Reset packager cache - `rm -fr $TMPDIR/react-*` or `node_modules/react-native/packager/packager.sh --reset-cache`\r\n- Clear watchman watches - `watchman watch-del-all`\r\n- Recreate the project from scratch"},"comment":{"url":"https://api.github.com/repos/facebook/react-native/issues/comments/244148641","html_url":"https://github.com/facebook/react-native/issues/4968#issuecomment-244148641","issue_url":"https://api.github.com/repos/facebook/react-native/issues/4968","id":244148641,"user":{"login":"centaur1","id":11053284,"avatar_url":"https://avatars.githubusercontent.com/u/11053284?v=3","gravatar_id":"","url":"https://api.github.com/users/centaur1","html_url":"https://github.com/centaur1","followers_url":"https://api.github.com/users/centaur1/followers","following_url":"https://api.github.com/users/centaur1/following{/other_user}","gists_url":"https://api.github.com/users/centaur1/gists{/gist_id}","starred_url":"https://api.github.com/users/centaur1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/centaur1/subscriptions","organizations_url":"https://api.github.com/users/centaur1/orgs","repos_url":"https://api.github.com/users/centaur1/repos","events_url":"https://api.github.com/users/centaur1/events{/privacy}","received_events_url":"https://api.github.com/users/centaur1/received_events","type":"User","site_admin":false},"created_at":"2016-09-01T17:18:33Z","updated_at":"2016-09-01T17:18:33Z","body":"So the TLDR; summary of what looks like at least one of the causes of the issue is:\r\nif the module directory is missing (1) index.js, (2) perhaps index.node, AND (3) the package.json does not include a \"main:\" entry like this:\r\n\r\n> { \"name\" : \"some-library\",\r\n>   \"main\" : \"./lib/some-library.js\" }\r\n\r\nthe module is not found and the error above is returned. And the error is returned showing that directory because most installations don't have that /Users/node_modules/  directory and so it errors out of the search there.\r\n\r\nFor crypto, it would be in a directory like this:\r\n/Users/me/Developer/test2/node_modules/crypto\r\n\r\n\r\n\r\n"}}
{"actor":{"display_login":"centaur1"}}