react-native: Naming collision error when running packager, caused by "lodash" and "yeoman-generator"

Description

In my project I am using "react-native": "0.36.0" and among the dependencies:

  • "lodash": "^4.15.0"
  • "yeoman-generator": "^0.24.1"

When using versions higher than "^3.10.1" for "lodash" and "0.21.2" for "yeoman-generator" I get naming collisions on "lodash", "inquirer" and "cli-width" when running packager.

Reproduction

Have the dependencies described above and run: react-native start --reset-cache Result:

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.

Solution

Using the same versions for "lodash" and "yeoman-generator" as the ones used in react-native@0.36.0 (i.e. "^3.10.1" for "lodash" and "0.21.2" for "yeoman-generator") fixes the issue, but changing them is really not an option for me at the moment. Is there any other possible fix?

Additional Information

  • React Native version: 0.36.0
  • Platform: both
  • Operating System: MacOS

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 27 (10 by maintainers)

Most upvoted comments

I was getting this issue with an application where I install with “yarn install” , instead of npm install. I did npm install -g npm, sudo rm -rf node_modules, and ran npm install, …npm deduped these files (yarn did not do any deduping)…and now i no longer get that error…perhaps that will help?

@lacker I did a rm -rf node_modules && npm install and it fixed it up.

Upgrading project to react-native 0.42.0 still is giving a lot of naming collision. I did node_modules delete and reinstall, but this did not help.

Upgrading a project to react-native 0.41.2 is giving me a bazillion of these errors

Running yarn install && npm dedupe worked for me too (an alternative solution of @susanner23 's solution)