New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Workarounds] Packager unable to resolve module from /Users/node_modules/ #4968

Open
satya164 opened this Issue Dec 24, 2015 · 497 comments

Comments

Projects
None yet
@satya164
Collaborator

satya164 commented Dec 24, 2015

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
@brentvatne

This comment has been minimized.

Show comment
Hide comment
@brentvatne

brentvatne Dec 24, 2015

Collaborator

cc @amasad

Collaborator

brentvatne commented Dec 24, 2015

cc @amasad

@amasad

This comment has been minimized.

Show comment
Hide comment
Contributor

amasad commented Dec 25, 2015

@amasad

This comment has been minimized.

Show comment
Hide comment
@amasad

amasad Dec 25, 2015

Contributor

That's really strange. Next time it happens can you list your watch roots? watchman watch-list

Contributor

amasad commented Dec 25, 2015

That's really strange. Next time it happens can you list your watch roots? watchman watch-list

@hufeng

This comment was marked as off-topic.

Show comment
Hide comment
@hufeng

hufeng Dec 25, 2015

yes, we met the same problem.

hufeng commented Dec 25, 2015

yes, we met the same problem.

@martinbigio

This comment has been minimized.

Show comment
Hide comment
@martinbigio

martinbigio Dec 25, 2015

Contributor

Do we have a consistent repro case? I've experienced this too.

Contributor

martinbigio commented Dec 25, 2015

Do we have a consistent repro case? I've experienced this too.

@Hybrid-Force

This comment has been minimized.

Show comment
Hide comment
@Hybrid-Force

Hybrid-Force Dec 25, 2015

Same problem here on version 0.17.0.

$ watchman watch-list
{
    "version": "3.8.0",
    "roots": []
}

Hybrid-Force commented Dec 25, 2015

Same problem here on version 0.17.0.

$ watchman watch-list
{
    "version": "3.8.0",
    "roots": []
}
@arypurnomoz

This comment has been minimized.

Show comment
Hide comment
@arypurnomoz

arypurnomoz Dec 25, 2015

I also got this problem when requesting for platform=ios

arypurnomoz commented Dec 25, 2015

I also got this problem when requesting for platform=ios

@udnisap

This comment has been minimized.

Show comment
Hide comment
@udnisap

udnisap Dec 25, 2015

Contributor

Do we have a way to recreate this? Any steps that might recreate.

Contributor

udnisap commented Dec 25, 2015

Do we have a way to recreate this? Any steps that might recreate.

@sgonyea

This comment has been minimized.

Show comment
Hide comment
@sgonyea

sgonyea 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 fresh npm 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 :).

sgonyea commented 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 fresh npm 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 :).

@udnisap

This comment has been minimized.

Show comment
Hide comment
@udnisap

udnisap Dec 26, 2015

Contributor

Is this only seen in npm 3?

npm 3 uses flat dependency structure. essentially node_modules are 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?

Contributor

udnisap commented Dec 26, 2015

Is this only seen in npm 3?

npm 3 uses flat dependency structure. essentially node_modules are 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

This comment has been minimized.

Show comment
Hide comment
@sgonyea

sgonyea Dec 26, 2015

I'm using npm 3.5.2. I'm not sure if it applies to npm 2.

sgonyea commented Dec 26, 2015

I'm using npm 3.5.2. I'm not sure if it applies to npm 2.

@amasad

This comment has been minimized.

Show comment
Hide comment
@amasad

amasad Dec 26, 2015

Contributor

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?

Contributor

amasad commented 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?

@Hybrid-Force

This comment has been minimized.

Show comment
Hide comment
@Hybrid-Force

Hybrid-Force Dec 26, 2015

@amasad No, I am using npm v2.14.7

Hybrid-Force commented Dec 26, 2015

@amasad No, I am using npm v2.14.7

@pcottle

This comment has been minimized.

Show comment
Hide comment
@pcottle

pcottle Dec 27, 2015

Contributor

👍 I'm seeing this too with npm 2.14.15 and node v5.1.0. I eventually got a fix by following @sgonyea's advice -- blew away the react-native npm module and reinstalled.

Interestingly none of:

  • watchman watch-del-all
  • rm -rf $TMPDIR/react-packager-*

fixed it for me. I experienced this after switching between two different React Native projects (one that relies on an older version). I ran the packager for both so maybe that will be part of the repro? It's not clear.

Either way I'm unblocked but this seems like a pretty nasty but. And googling for it yields a bunch of unrelated issues :P

Contributor

pcottle commented Dec 27, 2015

👍 I'm seeing this too with npm 2.14.15 and node v5.1.0. I eventually got a fix by following @sgonyea's advice -- blew away the react-native npm module and reinstalled.

Interestingly none of:

  • watchman watch-del-all
  • rm -rf $TMPDIR/react-packager-*

fixed it for me. I experienced this after switching between two different React Native projects (one that relies on an older version). I ran the packager for both so maybe that will be part of the repro? It's not clear.

Either way I'm unblocked but this seems like a pretty nasty but. And googling for it yields a bunch of unrelated issues :P

@skevy

This comment has been minimized.

Show comment
Hide comment
@skevy

skevy Dec 28, 2015

Collaborator

@pcottle and whoever else is/has experienced this issue - putting up a repo (with node_modules checked-in) would be AWESOME to help debug this. I too have experienced it, and so have people on my team (on both npm 2 and npm 3). In our case, resetting cache and doing watchman watch-del-all has fixed it (though obviously that's not the ideal solution)...but I realllllly wanna see this fixed, and would be happy to dive in to do the fixing. So if anyone can repro and put up the test case on Github, that would be super helpful. Obv post node version along with it so that we can duplicate the env.

Collaborator

skevy commented Dec 28, 2015

@pcottle and whoever else is/has experienced this issue - putting up a repo (with node_modules checked-in) would be AWESOME to help debug this. I too have experienced it, and so have people on my team (on both npm 2 and npm 3). In our case, resetting cache and doing watchman watch-del-all has fixed it (though obviously that's not the ideal solution)...but I realllllly wanna see this fixed, and would be happy to dive in to do the fixing. So if anyone can repro and put up the test case on Github, that would be super helpful. Obv post node version along with it so that we can duplicate the env.

@pcottle

This comment has been minimized.

Show comment
Hide comment
@pcottle

pcottle Dec 28, 2015

Contributor

@skevy will do if I run into it again! My bad, I hadn't thought of checking in the repos -- usually i think of the package.json as being the source of truth (so all else doesnt matter).

Others seem to be reporting that restarting helps, so I'm worried its due to something in-memory (which means repro-ing is harder).

Anyways I'm getting a new laptop from FB in a few days which means a full reinstall of everything, so I'll post back if I run into it again

Contributor

pcottle commented Dec 28, 2015

@skevy will do if I run into it again! My bad, I hadn't thought of checking in the repos -- usually i think of the package.json as being the source of truth (so all else doesnt matter).

Others seem to be reporting that restarting helps, so I'm worried its due to something in-memory (which means repro-ing is harder).

Anyways I'm getting a new laptop from FB in a few days which means a full reinstall of everything, so I'll post back if I run into it again

@philikon

This comment has been minimized.

Show comment
Hide comment
@philikon

philikon Dec 28, 2015

Contributor

FWIW, this error message is just the 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.

Contributor

philikon commented Dec 28, 2015

FWIW, this error message is just the 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.

@tukkajukka

This comment has been minimized.

Show comment
Hide comment
@tukkajukka

tukkajukka Dec 30, 2015

npm cache clean && npm install fixed my project.

I encountered this bug after upgrading React Native from 0.14 to 0.17. After the upgrade I installed a new module (react-native-swipeout) and tried to require it in my code but the module could not be located. At this point I also tried to require a new JS file I had created. That did not work either.

I'm using nvm 0.29.0, Node.js 5.3.0, and npm 3.3.12.

Edit: After the first time the problem disappeared I added another module (rn-router) and the same happened again. I got it working again when I closed the emulator and the packager script, and then ran clean & build in Xcode.

tukkajukka commented Dec 30, 2015

npm cache clean && npm install fixed my project.

I encountered this bug after upgrading React Native from 0.14 to 0.17. After the upgrade I installed a new module (react-native-swipeout) and tried to require it in my code but the module could not be located. At this point I also tried to require a new JS file I had created. That did not work either.

I'm using nvm 0.29.0, Node.js 5.3.0, and npm 3.3.12.

Edit: After the first time the problem disappeared I added another module (rn-router) and the same happened again. I got it working again when I closed the emulator and the packager script, and then ran clean & build in Xcode.

@martinbigio

This comment has been minimized.

Show comment
Hide comment
@martinbigio

martinbigio Dec 30, 2015

Contributor

Until we find the root cause for this it would be great showing a better error message with possible ways to fix the problem. For instance:

  • watchman watch-del-all
  • npm cache clean && npm install

Someone wants to send a PR for this? ;)

Contributor

martinbigio commented Dec 30, 2015

Until we find the root cause for this it would be great showing a better error message with possible ways to fix the problem. For instance:

  • watchman watch-del-all
  • npm cache clean && npm install

Someone wants to send a PR for this? ;)

@udnisap

This comment has been minimized.

Show comment
Hide comment
Contributor

udnisap commented Dec 31, 2015

udnisap added a commit to udnisap/react-native that referenced this issue Dec 31, 2015

udnisap added a commit to udnisap/react-native that referenced this issue Dec 31, 2015

@btsai

This comment has been minimized.

Show comment
Hide comment
@btsai

btsai Dec 31, 2015

I banged my head against a wall for the last 15 minutes before finding this thread.
I had added a new npm library (react-native-i18n) and when I did a new build, it was throwing the same error message "Unable to resolve module react-native-i18n from /Users/node_modules".
I resolved this by killing the react-native/packager script terminal window.
Thanks for having this thread!

react-native 0.17.0
npm -v 2.14.15
node -v v5.3.0

btsai commented Dec 31, 2015

I banged my head against a wall for the last 15 minutes before finding this thread.
I had added a new npm library (react-native-i18n) and when I did a new build, it was throwing the same error message "Unable to resolve module react-native-i18n from /Users/node_modules".
I resolved this by killing the react-native/packager script terminal window.
Thanks for having this thread!

react-native 0.17.0
npm -v 2.14.15
node -v v5.3.0

@alvaromb

This comment has been minimized.

Show comment
Hide comment
@alvaromb

alvaromb Jan 11, 2016

Contributor

I keep getting this error every time I install a dependency from Github. There are some deps that do not support RN 0.16.0 and onwards and I have cloned them in order to ignore .babelrc. I cant make those work.

Contributor

alvaromb commented Jan 11, 2016

I keep getting this error every time I install a dependency from Github. There are some deps that do not support RN 0.16.0 and onwards and I have cloned them in order to ignore .babelrc. I cant make those work.

@frederickfogerty

This comment has been minimized.

Show comment
Hide comment
@frederickfogerty

frederickfogerty Jan 14, 2016

@alvaromb find node_modules/ -type f -name .babelrc | grep -v packager | xargs rm # Removes all .babelrcs from node_modules is your friend

frederickfogerty commented Jan 14, 2016

@alvaromb find node_modules/ -type f -name .babelrc | grep -v packager | xargs rm # Removes all .babelrcs from node_modules is your friend

@alvaromb

This comment has been minimized.

Show comment
Hide comment
@alvaromb

alvaromb Jan 15, 2016

Contributor
Contributor

alvaromb commented Jan 15, 2016

@afilp

This comment has been minimized.

Show comment
Hide comment
@afilp

afilp Jan 18, 2016

I have the same problem with 'react-native-maps', whatever I try the build fails with this message that the module cannot be found.

afilp commented Jan 18, 2016

I have the same problem with 'react-native-maps', whatever I try the build fails with this message that the module cannot be found.

@tomkur

This comment has been minimized.

Show comment
Hide comment
@tomkur

tomkur Jan 19, 2016

Contributor

Similarly to @btsai, restarting packager fixed the problem for me. Is adding modules while packager is running supported?

I think the module resolution is working properly, i.e. first node_modules from project directory is checked and then after unsuccessful match (probably due to packager not noticing the change), the resolver goes up the file system hierarchy, up to /Users/node_modules/<module> and fails with the last error message, which will be Unable to resolve module <module> from /Users/node_modules/<module>

I've looked at react-native/packager/react-packager/src/DependencyResolver/DependencyGraph/ResolutionRequest.js which I believe is the culprit here, but it would be good if someone more knowledgeable looked at it as well.

Contributor

tomkur commented Jan 19, 2016

Similarly to @btsai, restarting packager fixed the problem for me. Is adding modules while packager is running supported?

I think the module resolution is working properly, i.e. first node_modules from project directory is checked and then after unsuccessful match (probably due to packager not noticing the change), the resolver goes up the file system hierarchy, up to /Users/node_modules/<module> and fails with the last error message, which will be Unable to resolve module <module> from /Users/node_modules/<module>

I've looked at react-native/packager/react-packager/src/DependencyResolver/DependencyGraph/ResolutionRequest.js which I believe is the culprit here, but it would be good if someone more knowledgeable looked at it as well.

@aprilmintacpineda

This comment has been minimized.

Show comment
Hide comment
@aprilmintacpineda

aprilmintacpineda Mar 29, 2018

You don't need to reinstall node_modules each and everytime, you can just restart the dev debugger and rebundle things up, it works for me.

aprilmintacpineda commented Mar 29, 2018

You don't need to reinstall node_modules each and everytime, you can just restart the dev debugger and rebundle things up, it works for me.

@morenoh149

This comment has been minimized.

Show comment
Hide comment
@morenoh149

morenoh149 Mar 30, 2018

Contributor

@aprilmintacpineda how do you do that exactly?

Contributor

morenoh149 commented Mar 30, 2018

@aprilmintacpineda how do you do that exactly?

@aprilmintacpineda

This comment has been minimized.

Show comment
Hide comment
@aprilmintacpineda

aprilmintacpineda Mar 31, 2018

ctrl+c, then npm run start or react-native start, you can also do react-native start --clear-cache, then if you restart your app on your Android emulator or iOS simulator, it will re-bundle.

aprilmintacpineda commented Mar 31, 2018

ctrl+c, then npm run start or react-native start, you can also do react-native start --clear-cache, then if you restart your app on your Android emulator or iOS simulator, it will re-bundle.

PiKatso added a commit to PiKatso/React-Native-Managment-App that referenced this issue Apr 1, 2018

solve for npm versioning error that references a common issue(faceboo…
…k/react-native#4968) buy reinstalling router flux library most up to date version
@fzymek

This comment was marked as off-topic.

Show comment
Hide comment
@fzymek

fzymek Apr 3, 2018

aaargh... this is issue sooo frustrating! I cannot work on my project because of this! resetting cache does not help ;(

fzymek commented Apr 3, 2018

aaargh... this is issue sooo frustrating! I cannot work on my project because of this! resetting cache does not help ;(

@shirakaba

This comment has been minimized.

Show comment
Hide comment
@shirakaba

shirakaba Apr 3, 2018

In an Expo app written in TypeScript, on a Mac, I found that I wasn't able to require any image assets – npm modules were importing fine, however. I followed the steps in the top comment, and all the other 600 comments, but to no avail. I did get it working in the end, however – although I'm not completely sure how. Here's a general health check:

  • Simply restart your computer. This may clear other caches that have been missed by the suggested cache-clearing steps in this thread.

  • If you're writing a relative path like, require("img/image.png"), try putting an explicit ./ in front, e.g.: require("img/image.png"). Whether this tells the packager(?) to look for the image again via an uncached path, or whether adding ./ really is functionally different, I don't know. This step may just be superstition.

  • Check whether the path is actually correct, of course. In a TypeScript project, all module imports with non-relative names are assumed to be relative to the baseUrl configured in tsconfig.json (defaulting to the location of tsconfig.json itself). TypeScript module resolution docs here. Whether this applies to require() imports too, I don't know.

  • In the Expo client, reload the javascript bundle.

I haven't said much here, and it surely won't apply to most people, but hopefully this might help someone.

shirakaba commented Apr 3, 2018

In an Expo app written in TypeScript, on a Mac, I found that I wasn't able to require any image assets – npm modules were importing fine, however. I followed the steps in the top comment, and all the other 600 comments, but to no avail. I did get it working in the end, however – although I'm not completely sure how. Here's a general health check:

  • Simply restart your computer. This may clear other caches that have been missed by the suggested cache-clearing steps in this thread.

  • If you're writing a relative path like, require("img/image.png"), try putting an explicit ./ in front, e.g.: require("img/image.png"). Whether this tells the packager(?) to look for the image again via an uncached path, or whether adding ./ really is functionally different, I don't know. This step may just be superstition.

  • Check whether the path is actually correct, of course. In a TypeScript project, all module imports with non-relative names are assumed to be relative to the baseUrl configured in tsconfig.json (defaulting to the location of tsconfig.json itself). TypeScript module resolution docs here. Whether this applies to require() imports too, I don't know.

  • In the Expo client, reload the javascript bundle.

I haven't said much here, and it surely won't apply to most people, but hopefully this might help someone.

@maggo

This comment has been minimized.

Show comment
Hide comment
@maggo

maggo Apr 3, 2018

@fzymek did you try to remove the metro cache dir rm -rf $TMPDIR/metro-cache-*? That's what fixed it for me.

maggo commented Apr 3, 2018

@fzymek did you try to remove the metro cache dir rm -rf $TMPDIR/metro-cache-*? That's what fixed it for me.

@Vadorequest

This comment has been minimized.

Show comment
Hide comment
@Vadorequest

Vadorequest Apr 3, 2018

@shirakaba Always use ./ for relative paths, because doing require("img/image.png") will first look into your node modules by default (and then maybe in your relative files, unsure), while require("./img/image.png") look relatively to the file.

Vadorequest commented Apr 3, 2018

@shirakaba Always use ./ for relative paths, because doing require("img/image.png") will first look into your node modules by default (and then maybe in your relative files, unsure), while require("./img/image.png") look relatively to the file.

@fzymek

This comment has been minimized.

Show comment
Hide comment
@fzymek

fzymek Apr 3, 2018

@maggo Yup. Tried it. I tried all rm's combinations mentioned above separately and in conjunction. it does not work for me ;( I also tried using yarn instead of npm

As soon as I type import of a new module I am getting this error. All I did was created simple react-native app and then I tried importing https://github.com/bttmly/nba module. as soon as I add

import NBA from 'nba'

I am getting this error. I am not even using any api from it. Without this statement it just works fine ;(

fzymek commented Apr 3, 2018

@maggo Yup. Tried it. I tried all rm's combinations mentioned above separately and in conjunction. it does not work for me ;( I also tried using yarn instead of npm

As soon as I type import of a new module I am getting this error. All I did was created simple react-native app and then I tried importing https://github.com/bttmly/nba module. as soon as I add

import NBA from 'nba'

I am getting this error. I am not even using any api from it. Without this statement it just works fine ;(

@09allude

This comment was marked as off-topic.

Show comment
Hide comment
@09allude

09allude Apr 12, 2018

everything in the top seemed to not work for me.
untitled789654

09allude commented Apr 12, 2018

everything in the top seemed to not work for me.
untitled789654

@malsagerM

This comment was marked as off-topic.

Show comment
Hide comment
@malsagerM

malsagerM Apr 16, 2018

i have the same issue and all the solution above does not work.

screen shot 1439-07-30 at 1 48 34 pm

malsagerM commented Apr 16, 2018

i have the same issue and all the solution above does not work.

screen shot 1439-07-30 at 1 48 34 pm

@wbattel4607

This comment has been minimized.

Show comment
Hide comment
@wbattel4607

wbattel4607 Apr 18, 2018

I just reinstalled my project from remote Git and am suddenly a victim of this issue.

Unable to resolve module `redux` from `/Users/wbattel4607/Desktop/project/node_modules/react-redux/lib/connect/mapDispatchToProps.js`: Module `redux` does not exist in the Haste module map
This might be related to https://github.com/facebook/react-native/issues/4968
To resolve try the following:
  1. Clear watchman watches: `watchman watch-del-all`.
  2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.
  3. Reset Metro Bundler cache: `rm -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`.
  4. Remove haste cache: `rm -rf /tmp/haste-map-react-native-packager-*`.
+ [[ false != true ]]
+ [[ ! -f /Users/wbattel4607/Library/Developer/Xcode/DerivedData/myapp-cvscqhbhrcowbrfzfirwmdiuyvfc/Build/Products/Release-iphoneos/myapp.app/main.jsbundle ]]
+ echo 'error: File /Users/wbattel4607/Library/Developer/Xcode/DerivedData/myapp-cvscqhbhrcowbrfzfirwmdiuyvfc/Build/Products/Release-iphoneos/myapp.app/main.jsbundle does not exist. This must be a bug with'
+ echo 'React Native, please report it here: https://github.com/facebook/react-native/issues'
+ exit 2

We do not, nor ever have used redux. Nothing in our project changed between when it was working and when it was not. None of the proposed solutions work for us. I've reset the cache, restarted my computer, reinstalled node_modules with both NPM and Yarn, etc.... I've been at this for hours and don't have anything left to try.

Environment:
  OS: macOS High Sierra 10.13.4
  Node: 6.10.3
  Yarn: 1.6.0
  npm: 5.6.0
  Watchman: 4.9.0
  Xcode: Xcode 9.3 Build version 9E145
  Android Studio: 3.0 AI-171.4408382

Packages: (wanted => installed)
  react: 16.3.1 => 16.3.1
  react-native: 0.55.3 => 0.55.3

How is this still an issue 3 years later?

wbattel4607 commented Apr 18, 2018

I just reinstalled my project from remote Git and am suddenly a victim of this issue.

Unable to resolve module `redux` from `/Users/wbattel4607/Desktop/project/node_modules/react-redux/lib/connect/mapDispatchToProps.js`: Module `redux` does not exist in the Haste module map
This might be related to https://github.com/facebook/react-native/issues/4968
To resolve try the following:
  1. Clear watchman watches: `watchman watch-del-all`.
  2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.
  3. Reset Metro Bundler cache: `rm -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`.
  4. Remove haste cache: `rm -rf /tmp/haste-map-react-native-packager-*`.
+ [[ false != true ]]
+ [[ ! -f /Users/wbattel4607/Library/Developer/Xcode/DerivedData/myapp-cvscqhbhrcowbrfzfirwmdiuyvfc/Build/Products/Release-iphoneos/myapp.app/main.jsbundle ]]
+ echo 'error: File /Users/wbattel4607/Library/Developer/Xcode/DerivedData/myapp-cvscqhbhrcowbrfzfirwmdiuyvfc/Build/Products/Release-iphoneos/myapp.app/main.jsbundle does not exist. This must be a bug with'
+ echo 'React Native, please report it here: https://github.com/facebook/react-native/issues'
+ exit 2

We do not, nor ever have used redux. Nothing in our project changed between when it was working and when it was not. None of the proposed solutions work for us. I've reset the cache, restarted my computer, reinstalled node_modules with both NPM and Yarn, etc.... I've been at this for hours and don't have anything left to try.

Environment:
  OS: macOS High Sierra 10.13.4
  Node: 6.10.3
  Yarn: 1.6.0
  npm: 5.6.0
  Watchman: 4.9.0
  Xcode: Xcode 9.3 Build version 9E145
  Android Studio: 3.0 AI-171.4408382

Packages: (wanted => installed)
  react: 16.3.1 => 16.3.1
  react-native: 0.55.3 => 0.55.3

How is this still an issue 3 years later?

@MayeuldP

This comment was marked as off-topic.

Show comment
Hide comment
@MayeuldP

MayeuldP Apr 18, 2018

Everything was working perfectly well too ! And suddenly, this one showed up, without any reasons. I mean "WTF React Native !" ! These kind of issues are very a pain !


EDIT : Tried deleting cache, killed packager, restarted, shuted down my computer and restarted it, deleting node_modules and npm install again............

== > Nothing worked \o/

MayeuldP commented Apr 18, 2018

Everything was working perfectly well too ! And suddenly, this one showed up, without any reasons. I mean "WTF React Native !" ! These kind of issues are very a pain !


EDIT : Tried deleting cache, killed packager, restarted, shuted down my computer and restarted it, deleting node_modules and npm install again............

== > Nothing worked \o/

@wbattel4607

This comment was marked as off-topic.

Show comment
Hide comment
@wbattel4607

wbattel4607 Apr 19, 2018

This is a disaster for our team. The only way to get past this is to go nuclear and create a whole new project. I still don't understand how nobody has found a concrete answer after all this time.

wbattel4607 commented Apr 19, 2018

This is a disaster for our team. The only way to get past this is to go nuclear and create a whole new project. I still don't understand how nobody has found a concrete answer after all this time.

@iOSleep

This comment has been minimized.

Show comment
Hide comment
@iOSleep

iOSleep Apr 19, 2018

this may be because of the metro cache, so you can add below func in your zshrc (bash_profile?)

# react-native
function rn-clean() {
  watchman watch-del-all
  rm -rf $TMPDIR/react-*
  rm -rf $TMPDIR/haste-*
  rm -rf $TMPDIR/metro-*
  npm start -- --reset-cache
}

iOSleep commented Apr 19, 2018

this may be because of the metro cache, so you can add below func in your zshrc (bash_profile?)

# react-native
function rn-clean() {
  watchman watch-del-all
  rm -rf $TMPDIR/react-*
  rm -rf $TMPDIR/haste-*
  rm -rf $TMPDIR/metro-*
  npm start -- --reset-cache
}
@t3chnoboy

This comment was marked as off-topic.

Show comment
Hide comment
@t3chnoboy

t3chnoboy Apr 19, 2018

@wbattel4607 Installing redux resolved the issue for me 🤷‍♂️

t3chnoboy commented Apr 19, 2018

@wbattel4607 Installing redux resolved the issue for me 🤷‍♂️

@binbinla

This comment was marked as outdated.

Show comment
Hide comment
@binbinla

binbinla Apr 25, 2018

@fzymek hello , is your problem been solved yet ?

binbinla commented Apr 25, 2018

@fzymek hello , is your problem been solved yet ?

@arnold-almeida

This comment was marked as outdated.

Show comment
Hide comment
@arnold-almeida

arnold-almeida Apr 26, 2018

In the end, this worked for me.

Environment:
  OS: macOS High Sierra 10.13.4
  Node: 9.11.1
  Yarn: 1.6.0
  npm: 5.6.0
  Watchman: 4.7.0
  Xcode: Xcode 9.3 Build version 9E145
  Android Studio: Not Found

Packages: (wanted => installed)
  react: 16.3.1 => 16.3.1
  react-native: 0.54.2 => 0.54.2

Ejected create-react-native-app with typescript using ("react-native-typescript-transformer")

#!/bin/bash

# Clean xcode generated crap
rm -rf ios/YOUR_PROJECT.xcodeproj/xcuserdata/

# Clean build
rm -rf ios/build/

# Remove relevant react-native cache files
rm -rf $TMPDIR/metro-*
rm -rf $TMPDIR/haste-*
rm -rf $TMPDIR/react-*

# sanity!
rm -rf node_modules

arnold-almeida commented Apr 26, 2018

In the end, this worked for me.

Environment:
  OS: macOS High Sierra 10.13.4
  Node: 9.11.1
  Yarn: 1.6.0
  npm: 5.6.0
  Watchman: 4.7.0
  Xcode: Xcode 9.3 Build version 9E145
  Android Studio: Not Found

Packages: (wanted => installed)
  react: 16.3.1 => 16.3.1
  react-native: 0.54.2 => 0.54.2

Ejected create-react-native-app with typescript using ("react-native-typescript-transformer")

#!/bin/bash

# Clean xcode generated crap
rm -rf ios/YOUR_PROJECT.xcodeproj/xcuserdata/

# Clean build
rm -rf ios/build/

# Remove relevant react-native cache files
rm -rf $TMPDIR/metro-*
rm -rf $TMPDIR/haste-*
rm -rf $TMPDIR/react-*

# sanity!
rm -rf node_modules
@fzymek

This comment was marked as outdated.

Show comment
Hide comment
@fzymek

fzymek Apr 26, 2018

@binbinla I haven't tried it for a while. I'll recheck when I have more time. Maybe this weekend.

fzymek commented Apr 26, 2018

@binbinla I haven't tried it for a while. I'll recheck when I have more time. Maybe this weekend.

@caitlintrussell

This comment has been minimized.

Show comment
Hide comment
@caitlintrussell

caitlintrussell Apr 27, 2018

I've had this same issue for the last day. We found something that worked for me, when nothing else seemed to; my global react-native install used a different version than my local. I had 54.1 local, 54.4 global. We removed the global and I'm up and running again!

caitlintrussell commented Apr 27, 2018

I've had this same issue for the last day. We found something that worked for me, when nothing else seemed to; my global react-native install used a different version than my local. I had 54.1 local, 54.4 global. We removed the global and I'm up and running again!

@Johnsalzarulo

This comment has been minimized.

Show comment
Hide comment
@Johnsalzarulo

Johnsalzarulo May 4, 2018

@caitlintrussell - So sorry to be a bother - very new to react-native:

  1. How did you know your global react-native install was a different version than your local?
  2. How do you go about fixing this issue?

Any direction you could offer would be greatly appreciated.

Thanks! 🙏

Johnsalzarulo commented May 4, 2018

@caitlintrussell - So sorry to be a bother - very new to react-native:

  1. How did you know your global react-native install was a different version than your local?
  2. How do you go about fixing this issue?

Any direction you could offer would be greatly appreciated.

Thanks! 🙏

@ryanostrom

This comment has been minimized.

Show comment
Hide comment
@ryanostrom

ryanostrom May 7, 2018

@jiang-yi-siphty when you try the react-native option for presets, what kind of error do you receive?

ryanostrom commented May 7, 2018

@jiang-yi-siphty when you try the react-native option for presets, what kind of error do you receive?

@lasthrun

This comment has been minimized.

Show comment
Hide comment
@lasthrun

lasthrun May 24, 2018

i fix it by:

  1. xcode open "yourReactNativeProject/ios"
  2. run Product -> Clean
  3. After Clean success, run Product -> Build
  4. fix all Build error
  5. work!

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.

lasthrun commented May 24, 2018

i fix it by:

  1. xcode open "yourReactNativeProject/ios"
  2. run Product -> Clean
  3. After Clean success, run Product -> Build
  4. fix all Build error
  5. work!

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.

@Yashesh9274

This comment has been minimized.

Show comment
Hide comment
@Yashesh9274

Yashesh9274 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 :
screenshot_1527841687

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

Yashesh9274 commented 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 :
screenshot_1527841687

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

@chrfrasco

This comment has been minimized.

Show comment
Hide comment
@chrfrasco

chrfrasco 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:

img_1953

Removing the import statement fixed it.

chrfrasco commented 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:

img_1953

Removing the import statement fixed it.

@hramos hramos changed the title from NPM modules get required from /Users/node_modules/ instead of the project directory to Packager unable to resolve module from /Users/node_modules/ Jun 12, 2018

@hramos

This comment has been minimized.

Show comment
Hide comment
@hramos

hramos Jun 12, 2018

Contributor

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.

Contributor

hramos commented 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.

@facebook facebook locked and limited conversation to collaborators Jun 12, 2018

@hramos hramos changed the title from Packager unable to resolve module from /Users/node_modules/ to [Workarounds] Packager unable to resolve module from /Users/node_modules/ Jun 27, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.