Closed
Description
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-*
ornode_modules/react-native/packager/packager.sh --reset-cache
- Clear watchman watches -
watchman watch-del-all
- Recreate the project from scratch
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
brentvatne commentedon Dec 24, 2015
cc @amasad
amasad commentedon Dec 25, 2015
cc @martinbigio @davidaurelio @cpojer
amasad commentedon Dec 25, 2015
That's really strange. Next time it happens can you list your watch roots?
watchman watch-list
hufeng commentedon Dec 25, 2015
martinbigio commentedon Dec 25, 2015
Do we have a consistent repro case? I've experienced this too.
Hybrid-Force commentedon Dec 25, 2015
Same problem here on version 0.17.0.
arypurnomoz commentedon Dec 25, 2015
I also got this problem when requesting for
platform=ios
udnisap commentedon Dec 25, 2015
Do we have a way to recreate this? Any steps that might recreate.
sgonyea commentedon Dec 25, 2015
I suspect that this is actually an npm bug. It seems that npm is secretly deleting installed packages in my project's
node_modules
directory, when I install an unrelated package. When it blows up with an error, it references/Users/node_modules/
because (I'm guessing) it's just searching up the directory tree 3-4 levels before giving up.re-running
npm install <module> —save
for each of the missing modules fixes this issue for me.edit: My guess is that React Native's complex dependency structure is just exposing npm's bugs.
edit 2: Yeah, you pretty much want to blow away your project's
node_modules
directory and do a freshnpm install
. I think the issue is extra common if you depend on modules that React Native also depends on (say, lodash).npm
just gets into a weird state with all the, ahem, flux :).720 remaining items