Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React-Native Packager Failure: Duplicate module name

This happened seemingly randomly during development. When trying to run npm start or react-native run-ios, I get the following error:

Failed to build DependencyGraph: @providesModule naming collision:
  Duplicate module name: react-native-vector-icons
  Paths: /Users/chandlervdw/Repos/Relay/mobile/node_modules/react-native/local-cli/rnpm/core/test/fixtures/files/package.json collides with /Users/chandlervdw/Repos/Relay/mobile/node_modules/react-native/Libraries/Animated/release/package.json

This error is caused by a @providesModule declaration with the same name accross two different files.
Error: @providesModule naming collision:
  Duplicate module name: react-native-vector-icons
  Paths: /Users/chandlervdw/Repos/Relay/mobile/node_modules/react-native/local-cli/rnpm/core/test/fixtures/files/package.json collides with /Users/chandlervdw/Repos/Relay/mobile/node_modules/react-native/Libraries/Animated/release/package.json

This error is caused by a @providesModule declaration with the same name accross two different files.
    at HasteMap._updateHasteMap (/Users/chandlervdw/Repos/Relay/mobile/node_modules/node-haste/lib/DependencyGraph/HasteMap.js:162:15)
    at /Users/chandlervdw/Repos/Relay/mobile/node_modules/node-haste/lib/DependencyGraph/HasteMap.js:140:25

Strangely, /Users/chandlervdw/Repos/Relay/mobile/node_modules/react-native/local-cli/rnpm/core/test/fixtures/files/package.json actually does list react-native-vector-icons as the name for the module???

If I delete that file, the error no longer happens but the packager gets stuck at 93% and complains about a completely irrelevent library not being found.

I blew away my repo and even reinstalled everything, including npm, rnpm, and even upgrading node. I'm running the same versions of everything as my teammates, who are able to run the packager without issues.

like image 319
chandlervdw Avatar asked Aug 11 '16 01:08

chandlervdw


2 Answers

Posting this as an answer just in case anybody else has this issue in future.

Running npm start with sudo permissions grants the correct privileges when nodes package manager is running the initial build phase. This only seems to happen if the shell/user that you are running from has restricted privileges. Force escalating privileges to sudo gives the package manager full control to complete the build.

like image 175
Halfpint Avatar answered Sep 22 '22 13:09

Halfpint


I was getting errors like

Failed to build DependencyGraph: @providesModule naming collision:
Failed to build DependencyGraph: @providesModule naming collision:
Duplicate module name: accepts
Duplicate module name: accepts

I solved it by deleting npm's cache .npm and rerunning packager with --reset-cache

rm -rf ~/.npm
like image 23
Shaheen Ghiassy Avatar answered Sep 19 '22 13:09

Shaheen Ghiassy