0

I am trying to run a react-native project on android emulator, but before I can get it to run properly, I need to run this command:

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

I got this command from this question, as I was having the problem described there. This worked yesterday, but I created a new project this morning, and now running the command hits an error with the following stack trace:

Error: Cannot find module 'jest-serializer'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at _load_jestSerializer (/Users/jareddembrun/Documents/Rot3/ReactNative/MyTechLoungeReactNativeMobileApp/node_modules/jest-haste-map/build/index.js:164:52)
at HasteMap._persist (/Users/jareddembrun/Documents/Rot3/ReactNative/MyTechLoungeReactNativeMobileApp/node_modules/jest-haste-map/build/index.js:781:25)
at _buildPromise._buildFileMap.then.then.hasteMap (/Users/jareddembrun/Documents/Rot3/ReactNative/MyTechLoungeReactNativeMobileApp/node_modules/jest-haste-map/build/index.js:425:16)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)

I ran npm install -g jest-serializer and got back

+ jest-serializer@23.0.1
updated 1 package in 0.498s

So the module must exist on my machine. Why is react-native bundle having trouble finding it?

Edit

Installing the jest-serializer locally fixed the problem, but why can't the react-native bundle script find the package if it's installed globally

jaredad7
  • 998
  • 2
  • 11
  • 33

1 Answers1

1

I just ran into this issue also.

Looking into it I found out jest-serializer was updated yesterday to "24.0.0-alpha.7". I had to install the previous version to get it working.

The command I ran in the project was

npm install jest-serializer@24.0.0-alpha.6
AndyC
  • 1,325
  • 1
  • 13
  • 23
  • Yeah, it looks like a local install fixes it, but I'm curious why the global install doesn't work. I'll see if removing the local install and install the 24 version globally fixes it. My local install was still the 23 version and it worked. EDIT: looks like it still fails to find it if it's only installed globally. – jaredad7 Dec 12 '18 at 16:53
  • Not sure why globally doesn't work vs locally. But I always try to keep all my packages locally because of version dependences issues. – AndyC Dec 12 '18 at 16:58
  • I wouldn't want this package local because the project itself doesn't depend on it, just this setup step. – jaredad7 Dec 12 '18 at 17:03