NPM modules get required from /Users/node_modules/ instead of the project directory #4968

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

Comments

Projects
None yet
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 tries to require the package from home directory instead of the project's node_modules directory, and the following wrror appears,

Unable to resolve module some-module from /Users/username/projectname/AwesomeProject/index.js: Invalid directory /Users/node_modules/some-module

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
Collaborator

brentvatne commented Dec 24, 2015

cc @amasad

Contributor

amasad commented Dec 25, 2015

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

hufeng commented Dec 25, 2015

yes, we met the same problem.

Contributor

martinbigio commented Dec 25, 2015

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

Same problem here on version 0.17.0.

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

I also got this problem when requesting for platform=ios

Contributor

udnisap commented Dec 25, 2015

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

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 :).

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 commented Dec 26, 2015

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

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?

@amasad No, I am using npm v2.14.7

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

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.

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

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.

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.

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

@pjcabrera pjcabrera referenced this issue in tradle/rn-nodeify Jan 8, 2016

Closed

It's not clear how to use this #2

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.

@irfaan irfaan referenced this issue in holmesal/react-native-ios-notification-actions Jan 13, 2016

Closed

Invalid directory error #1

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

Contributor

alvaromb commented Jan 15, 2016

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.

@afilp afilp referenced this issue in react-community/react-native-maps Jan 18, 2016

Closed

Invalid directory /Users/node_modules/react-native-maps #15

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.

29er commented Jan 21, 2016

wow this was a really annoying bug, spent a couple of hours on this one.
so far this has worked:
Delete/install the node_modules folder and reset cache

rm -rf node_modules && npm install
rm -fr $TMPDIR/react-* or node_modules/react-native/packager/packager.sh --reset-cache

@joshswan joshswan referenced this issue in joshswan/react-native-globalize Jan 21, 2016

Closed

"Unable to resolve module" - Install issue? #1

ghost pushed a commit that referenced this issue Jan 21, 2016

Improve error message
Summary:
There's a long standing issue on open source (#4968). Until someone gets some free bandwidth to fix it lets at the very least improve the error message to guide users to the issue and suggest workarounds.

public

Reviewed By: mkonicek

Differential Revision: D2849051

fb-gh-sync-id: ef7913442ceabcab2076141bd13ab1ceeb529759

MattFoley added a commit to skillz/react-native that referenced this issue Jan 21, 2016

Improve error message
Summary:
There's a long standing issue on open source (facebook#4968). Until someone gets some free bandwidth to fix it lets at the very least improve the error message to guide users to the issue and suggest workarounds.

public

Reviewed By: mkonicek

Differential Revision: D2849051

fb-gh-sync-id: ef7913442ceabcab2076141bd13ab1ceeb529759

nowaits commented Jan 26, 2016

+1 platform=ios

@btsai's tip did it for me, was still encountering the issue after running both:

npm install --force
npm cache clean && npm install

But after closing the react-native/packager script terminal window and the simulator and building from scratch all was well.

aylarov commented Jan 27, 2016

It's kind of big issue, met it first time after upgrading to 0.18.1 and actually workarounds don't work for me. It happens with the native module we develop:

Unable to resolve module createReactNativeComponentClass from /Users/aylarov/Work/iOSReactApp/VoximplantDemo/node_modules/react-native-voximplant/VoxImplant.ios.js: Invalid directory /Users/node_modules/createReactNativeComponentClass

Same here. After upgrading to 0.18.1:
UnableToResolveError: Unable to resolve module module from /Users/MyUser/MyAppName/node_modules/app-module-path/lib/index.js: Invalid directory /Users/node_modules/module
This error is consistent across at least two modules that I tried to install. All modules installed previous to the react-native upgrade work well.

Update: I cloned my project again in a different folder to see if there was something else wrong on my end and now even the modules that were working before give the same error:

UnableToResolveError: Unable to resolve module react-native-picker-android from /Users/MyUser/untitled folder/node_modules/react-native-picker/index.js: Invalid directory /Users/node_modules/react-native-picker-android
    at ResolutionRequest.js:356:1

Is there any quick workaround to at least be able to keep working with the current modules before this issue get fixed? Unfortunately now I can't even launch the app.

Thank you!

joewood commented Jan 29, 2016

Seeing this too, on and off when adding react-native-facebook-login. Error is:

uncaught error Error: UnableToResolveError: Unable to resolve module invariant from /Users/joewood/code/my-app/node_modules/react-native/Libraries/ReactIOS/NativeMethodsMixin.js: Invalid directory /Users/node_modules/invariant

  • react-native@0.18.1
  • node@4.2.3
  • npm@2.14.16

I see this is from the bundle script and/or the packager. Seems intermittent.

I tried to downgrade to 0.17 using
npm install --save react-native@0.17
but there is still no way I can get the project to work again. What else can be done to go back to a working copy ?

I had this a few times and unfortunately @29er's fix didn't seem to work for me. I am referring to this fix:
watchman watch-del-all
npm cache clean && npm install

What did seem to fix it (after killing the emulator and npm packager script) was deleting the node_modules folder and running the basic app init commands:

  1. react-native init AwesomeProject
  2. npm install

Running react-native init again won't destroy your project :) It will prompt you if you want to override the react-native generated files.

aylarov commented Jan 29, 2016

What did seem to fix it (after killing the emulator and npm packager script) was deleting the node_modules folder and running the basic app init commands:

  1. react-native init AwesomeProject
  2. npm install

Didn't work for me

Maybe also try running npm cache clean or @29er's complete suggestion after deleting the node_modules directory?

@aylarov I wonder if it's the way that you're exporting your node_module perhaps? I had some issues with a specific module but after various attempts with trial and error to originally fix this I can't be sure.

aylarov commented Jan 29, 2016

My issue was with my module, I fixed it, but there is definitely some issue if you copy/paste contents of the module w/o using npm install , I guess it is related to npm cache somehow.

Thank you @thomasbandit your solution fixed it:

  1. react-native init AwesomeProject
    (1a. copy my package.json to the folder)
    (1b. say "no" to all override requests)
  2. npm install

At least now I can continue development with no new modules. If I try to install a new module with npm and require it in the code:
var ModulePath = require('app-module-path');
I get the same error ```Invalid directory /User/node_modules/module
This looks a lot like a fairly simple path error. Is there any way to override or expand the list of path where it is looking for the node_modules?

@Sexycrets I think that if you just add any new modules to your package.json before running that npm install you should be good.

Contributor

MattFoley commented Jan 29, 2016

I'm actually having this same problem with my Docker build jobs. This is just when executing react-native bundle, not when the packager is running in a terminal. There's no watchman on this container, just Node 5.3. Is anyone else seeing this problem?

@thomasbandit unfortunately not. I tried to run npm install and it did not work. I deleted the node_modules folder again and then run npm install and I still get the same error on any the package that I installed after upgrading to 0.18.

Same exact issue if I delete the node_modules and redo all the npm init and then the npm install

I even created a clean project from scratch with react-native init xxx, installed the package npm install -save app-module-path and required it in index.ios.js as require('app-module-path').addPath(__dirname);

I have closed the packager terminal window, xcode, cleaned up the cache, removed the temp files. No dice, still same exact error.

Basically from the 0.18 upgrade any module I add never works.

Does anybody know how to change the path where react-native looks for the modules? It seems it keep looking in the /Users/node_modules/module folder instead using the project specific one. Am I missing something?

React Native version:
react-native-cli: 2.0.1
react-native: 0.47.1
Node version:
v6.11.2

yarn version:
v0.27.5

npm version :

v3.10.10

Errortype
unable to find module accesibilityInfo from node-modules/react-native/react-native-implementation.js..Is there any permanent solution.

Stucked from 1 week on this....

My package.json contains the following:
{
"name": "XYZ",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"babel-preset-react-native": "2.1.0",
"image-size": "^0.6.1",
"npm-git-install": "^0.3.0",
"react": "^15.6.1",
"react-native": "0.47.1",
"react-native-hideable-view": "^1.0.3",
"react-native-material-cards": "^1.0.5",
"react-native-responsive-dimensions": "^1.0.1",
"rn-viewpager": "^1.2.4"
},
"devDependencies": {
"babel-jest": "20.0.3",
"jest": "20.0.4",
"react-test-renderer": "16.0.0-alpha.12"
},
"jest": {
"preset": "react-native"
}
}

Is there any update?Feeling Helpless....

@REBOOTERS REBOOTERS referenced this issue in robinpowered/glamorous-native Sep 14, 2017

Open

npm install failed #69

Using npm start -- --reset-cache suggested by @mentalmedley fixed it for me. Hopefully stays fixed.

Tried Several times.does not work.

iShawnWang commented Sep 20, 2017

Try rollback yarn from 1.x to 0.27, this solved my problem, maybe yarn analyze the dependence between modules incorrectly.

Update

Maybe some npm module does't obay the semantic version rule, see : https://docs.npmjs.com/misc/semver#caret-ranges-123-025-004

Example

Module A depend on module XXX version 1.2.3
Module B depend on module XXX version 1.9.0

So, yarn or npm try to solve the dependence and the end using 1.9.0, because from 1.2.3 to 1.9.0 consider as unbreakable update. (such react.js 15.1 -> 15.4, but 15 -> 16 is break update !)

Then if module XXX doesn't obey the semantic version rule and delete some file or method, the Module A will show build error, because I rely on some function which module XXX v1.2.3 has but v1.9.0 not !!!

That's the reason why I am here , MDZZ
so maybe it's not the problem of yarn, npm, or react-native

Hoping this help ~

behzad888 added a commit to behzad888/react-native-root-siblings that referenced this issue Sep 24, 2017

EventEmitter NotFound
When packager cannot found this file, then an error occurred an facebook/react-native#4968

mukeshkamboj commented Sep 28, 2017

I am getting the below error. I have tried out the steps mentioned in the error console. But no luck.

	"react": "16.0.0-alpha.12",
	"react-native": "0.48.3",

error

The development server returned response error code: 500

URL: http://10.0.2.2:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false

Body:
{"from":"/Users/abc/development/react_native/node_modules/react-native-root-siblings/lib/AppRegistryInjection.js","to":"react-native/Libraries/EventEmitter/EventEmitter","message":"Unable to resolve module react-native/Libraries/EventEmitter/EventEmitter from /Users/abc/development/react_native/node_modules/react-native-root-siblings/lib/AppRegistryInjection.js: Module does not exist in the module map\n\nThis might be related to https://github.com/facebook/react-native/issues/4968\nTo resolve try the following:\n 1. Clear watchman watches: watchman watch-del-all.\n 2. Delete the node_modules folder: rm -rf node_modules && npm install.\n 3. Reset packager cache: rm -fr $TMPDIR/react-* or npm start -- --reset-cache.","name":"UnableToResolveError","type":"UnableToResolveError","errors":[{}]}
processBundleResult
BundleDownloader.java:170
access$100
BundleDownloader.java:39
onResponse
BundleDownloader.java:139
execute
RealCall.java:135
run
NamedRunnable.java:32
runWorker
ThreadPoolExecutor.java:1113
run
ThreadPoolExecutor.java:588
run
Thread.java:818

+1 after 0.49 upgrade

gxrxrdx commented Oct 24, 2017

I was having same problem, I just changed the import from:
import Teclado from 'teclado';
to
import Teclado from './teclado';
I used procmon (on windows) to spy filesystem calls, it looked for the file on the current directory, as expected.

@jxr202 jxr202 referenced this issue in kenvies/ONE-ReactNative Oct 26, 2017

Open

window10运行报错,watchman什么鬼装不了 #2

Contributor

QuantumInformation commented Oct 26, 2017

After taking a 6 month break from RN I started a new project to see if this issue is resolved, nope just a big BOOM

I can't believe RN is so popular when such a fundamental thing is still broken

After almost an hour of unsuccessful attempts of solving this problem with workarounds from this thread, I just reinstalled exact modules mentioned in the error message and it worked. For me it was react-native-elements and react-native-vector-icons.

For me using yarn solved all my problems!

elie222 commented Oct 26, 2017

Doing npm install instead of yarn install fixed the problems for me. I also deleted my node_modules folder before reinstall.

package version
react 16.0.0
react-native 0.50.3
npm 5.5.1
node 8.4.0
host os macOS
offending package: react-native-dotenv

I tried all the yarn and cache clearing suggestions here, thank you all for those, and none worked for me. I had to remove the package that the error was pointing to from my project all together.

  1. react-native uninstall [package name]
  2. rm -rf node_modules
  3. Delete the package from your package.json
  4. Delete package-lock.json
  5. npm install
  6. react-native link
  7. npm start -- --reset-cache
  8. react-native run-ios or react-native run-android

Of course this requires you can't use package X so not much of a solutions just help to get someone over the hump. This issue helped me figure it out: zetachang/react-native-dotenv#31

@Anishmprasad Anishmprasad referenced this issue in magicismight/react-native-root-siblings Nov 12, 2017

Open

Cannot build with react-native@0.43.1 #4

I have a repo that repros this:

git clone https://github.com/HandlebarLabs/currency-converter-starter.git
cd currency-converter-starter
git checkout module-3-lesson-1
npm install

By the way, that HandleBarLabs video tutorial is free and awesome! :-) . @HandlebarLabs I get the following issue:

Unable to resolve module `react-native/Libraries/Renderer/shims/ReactNativeBridgeEventPlugin` from `/Users/joel/src/react-native/currency-converter-starter/node_modules/react-native-gesture-handler/GestureHandler.js`: Module does not exist in the 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 packager cache: `rm -fr $TMPDIR/react-*` or `npm start -- --reset-cache`.

ABI19_0_0RCTFBQuickPerformanceLoggerConfigureHooks
ABI19_0_0RCTFBQuickPerformanceLoggerConfigureHooks
ABI19_0_0RCTFBQuickPerformanceLoggerConfigureHooks





CFRunLoopRunSpecific
GSEventRunModal
UIApplicationMain
Exponent

I tried all the cache cleaning etc and nothing worked. The only thing that helped was:
npm install --save react-native-gesture-handler@1.0.0-alpha.29.

Any ideas?

@joelpresence joelpresence referenced this issue in HandlebarLabs/currency-converter-starter Nov 14, 2017

Open

Starter fails with missing module #3

Hi joelpresence,Which Operating System are you using Windows or Linux.Try with Downgrading react version also.

tl;dr;

Install babel-preset-react-native and add it to your babelrc presets:

  1. Install the latest from create-react-native-app
  2. npm run eject
  3. npm i --save-dev babel-preset-react-native
  4. Edit your babelrc file presets hash to include "react-native" just before the default "babel-preset-react-native-stage-0/decorator-support".

Versions:

  • Mac OSX Sierra
  • Node v.8.6

Detailed Solution

I spent many days battling this issue. I attempted virtually every recommendation in this thread (and every combination of solutions) and none of them worked.

Here's a quick list of non-working solutions:

  • reverting versions of react/react-native vs. using newest versions
  • checking for version compatibility on every npm package
  • deleting package-lock.json
  • various cache clearing recommendaitons
  • watchman clears
  • uninstalling/reinstalling/updating watchman
  • installing/running yarn vs npm
  • removing all unnecessary plugins
  • removing ios/build folder
  • using babel-plugin-module-resolver vs. babel-plugin-module-alias
  • using various techniques of syntax withing babelrc for module-resolver vs. module-alias
  • etc

Solution
Add and configure the "babel-preset-react-native" npm package.

This leads me to believe that the default "babel-preset-react-native-stage-0/decorator-support" preset is insufficient. Does this seem likely to anyone who's a little more familiar with presets?

See my full (barebones) project architecture and configs (.babelrc and package.json) below:

Project directory structure:

android/
ios/
node_modules/
src/
.babelrc
package.json

.babelrc

{
  "presets": [
    "react-native",
    "babel-preset-react-native-stage-0/decorator-support"
  ],
  "env": {
    "development": {
      "plugins": [
        "transform-react-jsx-source"
      ]
    }
  },
  "plugins": [
    [
      "module-resolver", {
        "cwd": "babelrc",
        "root": "./src" // note, this is the directory for my app, for you this may be something different
      }
    ]
  ]
}

package.json

{
  "name": "app",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "babel-plugin-module-resolver": "^3.0.0",
    "babel-preset-react-native": "^4.0.0",
    "babel-preset-react-native-stage-0": "^1.0.1",
    "jest-expo": "^22.0.0",
    "react-test-renderer": "16.0.0-beta.5"
  },
  "scripts": {
    "start": "react-native start",
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "test": "node node_modules/jest/bin/jest.js --watch",
    "clean": "rm -rf node_modules && npm i && watchman watch-del-all && rm -fr $TMPDIR/react-* && rm -rf ios/build/ModuleCache/* && rm -rf ios/build"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "react": "16.0.0-beta.5",
    "react-native": "^0.49.5"
  }
}

Hancoson commented Dec 5, 2017

I performed:

  • Delete the node_modules folder -rm -rf node_modules
  • rm -fr $TMPDIR/react-*
  • watchman watch-del-all
  • yarn cache clean
  • yarn
  • Recreate the project from scratch
    But:
    image

What solved the issue for me:

@tamilandawweenalum#8093 yeah that was weird. I ended up just doing a:

rm -rf yarn.lock
rm -rf package-lock.json
yarn cache clean
rm -rf node_modules
watchman watch-del-all
yarn start 

package.json

{
	"name": "manager",
	"version": "0.0.1",
	"private": true,
	"scripts": {
		"clean": "rm -rf node_modules && npm i && watchman watch-del-all && rm -fr $TMPDIR/react-* && rm -rf ios/build/ModuleCache/* && rm -rf ios/buildn",
		"ios": "react-native run-ios",
		"start": "react-native start",
		"test": "jest",
		"flow": "flow",
		"flow:status": "flow status",
		"flow:ls": "flow ls",
		"flow:stop": "yarn run flow stop"
	},
	"dependencies": {
		"firebase": "^4.6.2",
		"react": "16.0.0",
		"react-native": "0.50.3",
		"react-native-router-flux": "^4.0.0-beta.24",
		"react-redux": "^5.0.6",
		"redux": "^3.7.2",
		"redux-thunk": "^2.2.0"
	},
	"devDependencies": {
		"babel-jest": "21.2.0",
		"babel-preset-react-native": "4.0.0",
		"flow-bin": "0.56.0",
		"jest": "21.2.1",
		"react-test-renderer": "16.0.0"
	},
	"jest": {
		"preset": "react-native"
	}
}

babel

{
  "presets": ["react-native"]
}

jonasdumas commented Dec 17, 2017

I had same error, but it was simple due because i didn't install the "PACKAGE" inside project folder. After installing it, clearing both cache (watchman and yarn) didn't work.

I just had to restart the react-native expo project after the install and it worked again.

My error was different below is the stacktrace.

error: bundling failed: UnableToResolveError: Unable to resolve module ieee754 from /Users/santanu/money/SecondAndroid/node_modules/buffer/index.js: Module does not exist in the module map or in these directories:
/Users/santanu/money/SecondAndroid/node_modules

I did npm install ieee754 --save and the error is vanished.

acb commented Jan 2, 2018

I was getting this error when trying to set up react-native with an existing repo. git clone and then npm install wasn't working. Tried basically everything in this thread, what ended up working for me was deleting the project folder entirely and doing:

react-native init myApp
cd myApp
<rm everything in this directory except node_modules>
git init
git remote add origin <url>
git pull origin master
npm install

Now everything's fine. Looks like that's the price I'll have to pay every time I use a new computer.

@Nbsaw Nbsaw referenced this issue in Nbsaw/notes Jan 7, 2018

Open

React Native Explore #36

lopno commented Jan 14, 2018

I was getting this error because I was using file system modules (fs, fs-extra, xml2json).
Stopping using these or switching to a react native implementation fixed the issue.

My errror is 'Unable to resolve module assert'.
run npm install assert --save, it worked.

This happened to me twice, npm modules get required from /users/node_module and not from my working directory. I figured that on both cases, I did an npm install while a terminal is running npm run start, at first I did rm -rf node_modules && npm install to fix the issue, then the second time around I simply restarted the dev server and it worked.

rzane commented Jan 16, 2018

In my case, I was trying to use node standard library modules, like url and querystring. By installing packaged versions of those libraries as NPM packages (url and querystring literally), everything worked right away.

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