最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - React Native: @providesModule declaration with the same name across two different files - Stack Overflow

matteradmin3PV0评论

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 ponents 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.

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 ponents 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.

Share Improve this question asked Feb 10, 2017 at 15:36 Johnny CopperstoneJohnny Copperstone 7931 gold badge6 silver badges15 bronze badges 2
  • Shouldn't RN be a peer dependency of your UI package? – Etheryte Commented Feb 10, 2017 at 15:44
  • 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 issue – Johnny Copperstone Commented Feb 10, 2017 at 16:15
Add a ment  | 

2 Answers 2

Reset to default 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

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.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far