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,
var someModule = require('some-module');
It is unable to resolve the package and the following error appears,
Unable to resolve module some-module from /Users/username/projectname/AwesomeProject/index.js: Invalid directory /Users/node_modules/some-module
This error message is a symptom of the packager not being able to find some-module. It'll walk up the directory tree until it finds node_modules/some-module. It just so happens that /Users is the last directory to try, hence the weird /Users/node_modules directory in the error message (h/t @philikon).
Workarounds
Currently, the workarounds seem to be,
- Delete the
node_modules folder - rm -rf node_modules && npm install
- Reset packager cache -
rm -fr $TMPDIR/react-* or node_modules/react-native/packager/packager.sh --reset-cache
- Clear watchman watches -
watchman watch-del-all
- Recreate the project from scratch
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-modulein a file, for example,It is unable to resolve the package and the following error appears,
This error message is a symptom of the packager not being able to find
some-module. It'll walk up the directory tree until it findsnode_modules/some-module. It just so happens that/Usersis the last directory to try, hence the weird/Users/node_modulesdirectory in the error message (h/t @philikon).Workarounds
Currently, the workarounds seem to be,
node_modulesfolder -rm -rf node_modules && npm installrm -fr $TMPDIR/react-*ornode_modules/react-native/packager/packager.sh --reset-cachewatchman watch-del-all