16

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.

chandlervdw
  • 3,197
  • 4
  • 19
  • 21
  • 1
    I know it sounds silly, but have you tried running with sudo permissions, I had a similar error when trying to build react-native for Android and running with sudo resolved the conflict. – Halfpint Aug 11 '16 at 01:13
  • 1
    @Alex you've got to be kidding. That worked! But WHYYYYYYY?!?! I lost a whole day's worth of work because of this... – chandlervdw Aug 11 '16 at 01:22
  • 1
    @chandlervdw trust me buddy, I had the exact thing happen to me this week, sorry you had to waste so much time on this error...I was banging my head against a wall too, also exhausted all other avenues as you did! Don't you just love the npm package manager sometimes lol! Glad its sorted for you :) – Halfpint Aug 11 '16 at 01:25
  • 2
    My guess is that when building that package it needs to access some restricted resources which required the elevated permissions that sudo grants...I just wish the error codes weren't so vague! – Halfpint Aug 11 '16 at 01:27
  • Thanks - Spent hours on a weekend getting random red screens, unbelievable! Great Tip, bookmarked! – VineFreeman Jul 04 '17 at 22:37

4 Answers4

8

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.

Halfpint
  • 3,967
  • 9
  • 50
  • 92
4

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
Shaheen Ghiassy
  • 7,397
  • 3
  • 40
  • 40
  • This should be the accepted answer as I find the other answer kind of 'cheating' since I normally never used `sudo` – Greg Oct 25 '16 at 12:57
  • @Greg Let's not forget that "Sudo" doesn't exist on windows, and shouldn't be used to get around permission errors. – Hobbyist Apr 18 '17 at 05:14
4

sudo or chown did not fix it for me. I get the same error from the same library, very odd:

Failed to build DependencyGraph: @providesModule naming collision:
 Duplicate module name: react-native-vector-icons
  Paths: /Users/collumj/research/k9fresh/ios/build/Build/Products/Debug-iphonesimulator/kisharNine.app/package.json collides with /Users/collumj/research/k9fresh/node_modules/react-native/local-cli/core/__fixtures__/files/package.json

No need for sudo when I encounter this.

Warning: destructive, check in first.

rm -rf android ios
git reset --hard
npm start

This fixes it every time. RN 0.39.2

edit: later, I think I fixed this by unlinking the react-native-vector-icons lib; I think the instructions I got made me double up on the linking or were out of date somehow.

jcollum
  • 43,623
  • 55
  • 191
  • 321
3

After cleaning the nvm cache and reinstalling all node_modules I realized I was having this issue because of react-native-router-flux.

I fixed it with a downgrade from react-native-router-flux@3.38.1 to react-native-router-flux@3.38.0

More details here: https://github.com/aksonov/react-native-router-flux/issues/1816

Florin Dobre
  • 9,872
  • 3
  • 59
  • 93