React Native: @providesModule declaration with the same name across two different files
Asked Answered
D

2

6

We've got two repos, both of which have react-native as dependencies; one being the actual RN app and the other a UI package with a number of custom react-native components in it.

When I symlink (using npm link) the UI package with the RN app and try start the js server, it throws the follow error:

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

It seems to be because it's picking up the same RN files inside the UI package's copy of react-native.

I know there's a problem with watchman not working with symlinks, however I think this is different - to do with there being two react-native modules. Does anyone know a way to get around this please? I've made sure that both are the same version number but still nothing.

Dimitri answered 10/2, 2017 at 15:36 Comment(2)
Shouldn't RN be a peer dependency of your UI package?Ab
Seems to have sorted that issue thanks @Nit. Although it can't seem to find the index.ios.js even though it's all there - but this must be a separate issueDimitri
H
13

This has been destroying my day as well. as a quick workaround, you can just go delete the folder of react-native out of the node_modules folder within react-native-router-flux.(node_modules > react-native-router-flux > node_modules > react-native) Ugly, but will at least get you up and running for the time being

Hanley answered 9/5, 2017 at 16:40 Comment(1)
Happened for me too completely out of nowhere... but this will work for now. Thanks.Impuissant
L
0

This happens when you have two of the same-named modules in your dependency tree, usually because you have two copies of a package with has a @providesModule declaration (typically react-native, it seems). A full example error:

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: yargs
  Paths:
  /Users/me/Documents/git/MyProject/node_modules/react-native-macos/node_modules/yargs/package.json collides with:
  /Users/me/Documents/git/MyProject/node_modules/react-native/node_modules/yargs/package.json

This is symptomatic of my working on a fork of React Native, react-native-macos, yet having installed react-native into the same repo.

In my case, I simply had to uninstall my self-installed react-native to proceed; in @Hafiz's case, his react-native-router-flux dependency was bundling its own copy of react-native internally, so he had to manually delete it – that fault is on the repo owners. Happily, they have resolved the issue since.

Lamarckian answered 6/5, 2018 at 9:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.