kimxogus / react-native-version-check

A version checker for react-native applications
MIT License
722 stars 179 forks source link

"Error: jest-haste-map: @providesModule naming collision" for react-native #85

Closed stdavis closed 5 years ago

stdavis commented 5 years ago

After installing react-native-version-check-expo@3.2.0, my expo app fails to build with the following error message:

Starting Metro Bundler on port 19001.
(node:29145) UnhandledPromiseRejectionWarning: Error: jest-haste-map: @providesModule naming collision:
  Duplicate module name: react-animated
  Paths: /Users/stdavis/Documents/Projects/working/deps-test/node_modules/react-native-version-check/src/node_modules/react-native/Libraries/Animated/release/package.json collides with /Users/stdavis/Documents/Projects/working/deps-test/node_modules/react-native/Libraries/Animated/release/package.json

This error is caused by a @providesModule declaration with the same name across two different files.
    at setModule (/Users/stdavis/Documents/Projects/working/deps-test/node_modules/jest-haste-map/build/index.js:462:17)
    at workerReply (/Users/stdavis/Documents/Projects/working/deps-test/node_modules/jest-haste-map/build/index.js:512:9)
    at process._tickCallback (internal/process/next_tick.js:68:7)

(node:29145) 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: 2)
(node:29145) [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.

To reproduce:

  1. expo init (blank)
  2. expo start (verify that it starts up without errors)
  3. npm i react-native-version-check-expo
  4. expo start (this returns the error message above)

node_modules/react-native-version-check/src/node_modules seems to contain all sorts of packages that don't seem appropriate (including the duplicate react-native package that causes the error above) for a regular npm install. It's almost as if something installed the devDependencies for the react-native-version-check package. I'm not an expert on how npm installs packages but this seems incorrect to me.

This is an incredibly useful package and I'm thankful for the maintainers' work on it. If someone wants to point me in the right direction, I'd be happy to take a stab at a PR to fix this. However, I'm at a loss on where to begin.

NodeJS: v10.15.3 NPM: 6.4.1 expo-cli: 2.17.3

stdavis commented 5 years ago

I get the same error message using yarn as well.

stdavis commented 5 years ago

I was able to get things working again by pinning both packages to 3.1.0:

"react-native-version-check": "3.1.0",
"react-native-version-check-expo": "3.1.0"

Maybe there was something that caused lerna to publish react-native-version-check/src/node_modules?

kimxogus commented 5 years ago

lerna publish didn't respect .npmignore and that caused react-native-version-check/src/node_modules to be published. It was fixed in #86 and published as v3.2.1

stdavis commented 5 years ago

Confirmed that v3.2.1 is working for me. Thank you!!!