React-native: Error: Cannot find module 'jest-haste-map'

Created on 17 Sep 2018  路  4Comments  路  Source: facebook/react-native

Environment

React Native Environment Info:
System:
OS: macOS High Sierra 10.13.6
CPU: x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Memory: 85.32 MB / 16.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 8.11.4 - ~/.nodenv/versions/8.11.4/bin/node
npm: 5.6.0 - ~/.nodenv/versions/8.11.4/bin/npm
SDKs:
iOS SDK:
Platforms: iOS 11.4, macOS 10.13, tvOS 11.4, watchOS 4.3
IDEs:
Android Studio: 3.1 AI-173.4907809
Xcode: 9.4.1/9F2000 - /usr/bin/xcodebuild
npmPackages:
react: 16.4.1 => 16.4.1
react-native: 0.56.0 => 0.56.0
npmGlobalPackages:
react-native-cli: 2.0.1

Description

I have a React Native project created with react-native init. It runs fine. Howver it fails in Bitrise. I run clone the repo on a completely new mac, and running react-native run-ios --simulator='iPhone X' fails with

Error: Cannot find module 'jest-haste-map'

I actually tracked everything (Pods, lib, node_modules) to git to avoid these problems. To solve this, I run npm install jest-haste-map, then I get

Error: Cannot find module 'jest-worker'

Then I run npm install jest-worker. It then runs fine, but bundler shows that

Cannot find module 'jest-serializer'

I then run npm install jest-serializer

Now I get

Metro Bundler ready.

Loading dependency graph...(node:74975) UnhandledPromiseRejectionWarning: Error: `fsevents` unavailable (this watcher can only be used on Darwin)
    at new FSEventsWatcher (/Users/khoa/XcodeProject2/foodshopguest/node_modules/sane/src/fsevents_watcher.js:41:11)
    at createWatcher (/Users/khoa/XcodeProject2/foodshopguest/node_modules/jest-haste-map/build/index.js:780:23)
    at Array.map (<anonymous>)
    at HasteMap._watch (/Users/khoa/XcodeProject2/foodshopguest/node_modules/jest-haste-map/build/index.js:936:44)
    at _buildPromise._buildFileMap.then.then.hasteMap (/Users/khoa/XcodeProject2/foodshopguest/node_modules/jest-haste-map/build/index.js:355:23)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
(node:74975) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:74975) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I then follow https://github.com/expo/expo/issues/854 and run

npm r -g watchman
brew install watchman

Now I get

Error: While trying to resolve module react-devtools-core
However, this package itself specifies a main module field that could not be resolved 

Reproducible Demo

Let us know how to reproduce the issue. Include a code sample, share a project, or share an app that reproduces the issue using https://snack.expo.io/. Please follow the guidelines for providing a MCVE: https://stackoverflow.com/help/mcve

Ran Commands Locked

Most helpful comment

In my case it couldn't find the module 'jest-serializer' on a brand new react-native project after running npm start. Perplexing.
However, following onmyway133 suggestion, after installing jest-haste-map, jest-serializer and jest-worker it suddenly worked. I don't really understand this.

All 4 comments

It looks like you are using an older version of React Native. Please update to the latest release, v0.57 and verify if the issue still exists.

The ":rewind:Old Version" label will be removed automatically once you edit your original post with the results of running react-native info on a project using the latest release.

I am closing this issue because it does not appear to have been verified on the latest release, and there has been no followup in a while.

If you found this thread after encountering the same issue in the latest release, please feel free to create a new issue with up-to-date information by clicking here.

It looks like you are using an older version of React Native. Please update to the latest release, v0.57 and verify if the issue still exists.

The "Old Version" label will be removed automatically once you edit your original post with the results of running react-native info on a project using the latest release.

still facing same issue. after upgrading to v0.57.7

In my case it couldn't find the module 'jest-serializer' on a brand new react-native project after running npm start. Perplexing.
However, following onmyway133 suggestion, after installing jest-haste-map, jest-serializer and jest-worker it suddenly worked. I don't really understand this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jlongster picture jlongster  路  3Comments

lazywei picture lazywei  路  3Comments

ghost picture ghost  路  3Comments

axelg12 picture axelg12  路  3Comments

oney picture oney  路  3Comments