Skip to content
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

Naming collision error when running react-native packager #2222

Closed
andreipt opened this issue Dec 5, 2016 · 10 comments
Closed

Naming collision error when running react-native packager #2222

andreipt opened this issue Dec 5, 2016 · 10 comments

Comments

@andreipt
Copy link

andreipt commented Dec 5, 2016

Do you want to request a feature or report a bug?
Report a bug

What is the current behavior?
In a react-native project I get the following naming collision error while running packager, that seems to come from jest-haste-map:

jest-haste-map: @providesModule naming collision:
  Duplicate module name: inquirer
  Paths: /CoolProject/node_modules/react-native/node_modules/yeoman-generator/node_modules/inquirer/package.json collides with /CoolProject/node_modules/react-native/node_modules/inquirer/package.json

This warning is caused by a @providesModule declaration with the same name across two different files.
jest-haste-map: @providesModule naming collision:
  Duplicate module name: lodash
  Paths: /CoolProject/node_modules/react-native/node_modules/lodash/package.json collides with /CoolProject/node_modules/react-native/node_modules/inquirer/node_modules/lodash/package.json

This warning is caused by a @providesModule declaration with the same name across two different files.
jest-haste-map: @providesModule naming collision:
  Duplicate module name: cli-width
  Paths: /CoolProject/node_modules/react-native/node_modules/yeoman-generator/node_modules/cli-width/package.json collides with /CoolProject/node_modules/react-native/node_modules/cli-width/package.json

This warning is caused by a @providesModule declaration with the same name across two different files.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal repository on GitHub that we can npm install and npm test.

  1. Dependencies for which running react-native start --reset-cache throws the "naming collision error":
"dependencies": {
    "inquirer": "^0.10.1",
    "lodash": "^4.16.4",
    "yeoman-generator": "^0.24.1",
    "react": "15.3.1",
    "react-native": "0.36.0"
  },
  1. Dependencies for which react-native start --reset-cache is executed successfully:
"dependencies": {
    "inquirer": "^0.12.0",
    "lodash": "^3.10.1",
    "yeoman-generator": "^0.21.2",
    "react": "15.3.1",
    "react-native": "0.36.0"
  },

What is the expected behavior?
Packager should run successfully.

Run Jest again with --debug and provide the full configuration it prints. Please mention your node and npm version and operating system.
npm: 3.10.8
node: v7.0.0

@thymikee
Copy link
Collaborator

Does this still happens on Jest 18.1 and react-native 38+ with Jest's "preset": "react-native" in config?

@RyanMitchellWilson
Copy link

This is still happening, I'm using Jest 18.1 with react-native 0.41

@xareelee
Copy link

xareelee commented Apr 10, 2017

Same issue here.

I'm using Jest 19.0.2 with react-native 0.43.2. It was fine with react-native 0.42.0.

I made an issue on the react-native page too: facebook/react-native#13364

@rajeshkos
Copy link

Can anybody please provide me solution for this, i have same issue.

@bherila
Copy link

bherila commented Apr 21, 2017

It is broken with react-native 0.43.2

It is working with this packages.config

  "dependencies": {
    "fetch-ponyfill": "^4.0.0",
    "lodash": "^4.17.4",
    "moment": "^2.18.1",
    "react": "~15.4.1",
    "react-native": "0.42",
    "react-native-code-push": "^2.0.2-beta",
    "react-native-easy-grid": "^0.1.8",
    "react-native-loading-spinner-overlay": "^0.4.4",
    "react-native-modalbox": "^1.3.9",
    "react-native-reactive": "0.0.3",
    "react-native-router-flux": "^3.38.0",
    "react-native-scrollable-tab-view": "^0.7.4",
    "react-native-simple-store": "^1.1.0",
    "react-native-tableview": "^1.7.0",
    "react-native-vector-icons": "^4.0.1",
    "url-parser": "0.0.1"
  },
  "devDependencies": {
    "babel-jest": "19.0.0",
    "babel-preset-react-native": "1.9.1",
    "jest": "19.0.2",
    "querystring": "^0.2.0",
    "react-test-renderer": "15.4.2",
    "url": "^0.11.0"
  },

also see: https://github.com/andreipt/VanillaReactNative

@aleclarson
Copy link
Contributor

aleclarson commented Jan 31, 2019

I'm running into this. 😢

Is Jest supposed to deduplicate packages with the same name and version? There should at least be an option for such a thing. It would definitely help solve facebook/metro#350.

Jest version: 23.6.0

@SimenB
Copy link
Member

SimenB commented Jan 31, 2019

Jest has removed its haste support, the implementation comes from RN's preset: https://github.com/facebook/react-native/blob/02697291ff41ddfac5b85d886e9cafa0261c8b98/jest/hasteImpl.js

Probably worth an issue on RN? I think this isn't something to fix here, I might be wrong, though!

@aleclarson
Copy link
Contributor

@SimenB I'm referring to this error specifically:

https://github.com/facebook/jest/blob/adf2b3c73f967e9c07308c512c4df300d770f295/packages/jest-haste-map/src/index.js#L433-L443

There's currently no way to configure jest-haste-map to ignore "module" collisions (package collisions in my case) when they have identical SHA-1 strings.

@aleclarson
Copy link
Contributor

jest-haste-map is not the right place to be checking for package collisions (at least in Metro's case), because it doesn't discriminate between dependencies and devDependencies. Ideally, it would ignore devDependencies, but it's impossible to do that without building a dependency graph (which is something that Metro does).

With that said, I guess Metro should just disable the throwOnModuleCollision option and maintain its own package cache. Otherwise, jest-haste-map will remove "duplicate" packages from the module map, which Metro does not respond kindly to.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants