Repository navigation
Closed
Labels
BugHelp Wanted
Issues ideal for external contributors.Issues ideal for external contributors.JavaScriptResolution: LockedThis issue was locked by the bot.This issue was locked by the bot.Tech: Bundler 📦This issue is related to the bundler (Metro, Haul, etc) used.This issue is related to the bundler (Metro, Haul, etc) used.📮Known IssuesThis indicates an issue that refers to a bug or limitation of RN that is not currently being handledThis indicates an issue that refers to a bug or limitation of RN that is not currently being handled
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-moduleThis 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_modulesfolder -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
Reacted by Leonard Smith, Frank Wilson, tjboAtVidao, Bilal Budhani, Ivan, Felipe Torres (fforres), Xing Zheng, André König, Sergey Korochansky, José Ribeiro and 222 more
Reacted by JiangJieFS, xilouwangshi, DANGerous, Rob Moorman, Montique Willis, Pawan, 王大虎, Andrea Cabral, SeeTechnologies, Filod Lin and 188 more
Reacted by Nikos, kevinder, Cody Wall, Simon Guo, Michael Dobekidis, Hossam Hassan, Zura Mestiashvili, Key, Hisham Mubarak, Ali Ghanavatian and 9 more
Reacted by Dan Barbarito, Ali Torki, 小动物保护协会, Jessica, Babar Hussain, Rahul Yadav, Ilja, Nikos, Nontachai Tantiponsawas, Cody Wall and 13 more
Reacted by Artem Stalpouski, scartick, Collen, Vítor Mariano, Dima Kharitonov, Alexander Ivkin, Marek Kotewicz, Nicolas Perriault, Denys Bushuliak, Michael Henke and 80 more
Reacted by Rahul Yadav, Nikos, Sydney Cohen, Cody Wall, hossein, Andrew Andilevko, CryptoX, Simon Guo, tingxu.wang, Osvaldo Matos-Junior and 12 more
Metadata
Metadata
Assignees
Labels
BugHelp Wanted
Issues ideal for external contributors.Issues ideal for external contributors.JavaScriptResolution: LockedThis issue was locked by the bot.This issue was locked by the bot.Tech: Bundler 📦This issue is related to the bundler (Metro, Haul, etc) used.This issue is related to the bundler (Metro, Haul, etc) used.📮Known IssuesThis indicates an issue that refers to a bug or limitation of RN that is not currently being handledThis indicates an issue that refers to a bug or limitation of RN that is not currently being handled
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-listhufeng 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=iosudnisap 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_modulesdirectory, 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> —savefor 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_modulesdirectory 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).npmjust gets into a weird state with all the, ahem, flux :).udnisap commentedon Dec 26, 2015
Is this only seen in npm 3?
npm 3 uses flat dependency structure. essentially
node_modulesare not resides in individual packages but only on the top level. if we have references like{somepackage}/node_modules/...we will have issue. Does it ring any bells?sgonyea commentedon Dec 26, 2015
I'm using npm 3.5.2. I'm not sure if it applies to npm 2.
amasad commentedon Dec 26, 2015
I don't think we've tested on npm 3. Although the node resolution algorithm (which we implement) should still work. Are all of you seeing this using npm 3?
499 remaining items
anon-r-7 commentedon May 7, 2018
@jiang-yi-siphty when you try the react-native option for presets, what kind of error do you receive?
lasthrun commentedon May 24, 2018
i fix it by:
i think it cause by we had doing some wrong script and it had edit some xcode setting file that git ignored, so we can not easier to solve it by revert or rebuild the project.
YasheshSavani commentedon Jun 1, 2018
Hello,
I have installed firebase in react-native using command " npm install --save firebase" then whenever i import " import firebase from 'firebase'; " below error shows up i have tried also installing 'react-native-firebase' but it doesn't work that well.
I have got this error as below during running my application on device :

EDIT:
The error which shown above is solved by rollbacking to firebase version 5.0.4 to 5.0.3.
As an extra information i found out that firebase@5.0.4 run smoothly on ios but it is not much compatible to android at this time. Therefore if any body wants to use it on android they can install firebase by command:
" npm i --save firebase@5.0.3 "
Thank you
christianscott commentedon Jun 4, 2018
This just happened to me because VSCode had erroneously inserted
import { Utils } from "handlebars"into one of my files. Super cryptic error message though:Removing the import statement fixed it.
[-]NPM modules get required from /Users/node_modules/ instead of the project directory[/-][+]Packager unable to resolve module from /Users/node_modules/[/+]hramos commentedon Jun 12, 2018
Locking as recent activity appears unrelated to the original discussion around what caused the packager to fail in this manner. Now that the packager has moved to https://github.com/facebook/metro, we might want to move the discussion to an issue on that repo instead.
[-]Packager unable to resolve module from /Users/node_modules/[/-][+][Workarounds] Packager unable to resolve module from /Users/node_modules/[/+]hramos commentedon Jan 29, 2019
Please continue discussion over at https://github.com/facebook/metro