Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native Duplicate module naming collision

When I install a specific npm package to my react native project and attempt to run it i get the following error:

This error is caused by a @providesModule declaration with the same name accross two different files.
Error: @providesModule naming collision:
Duplicate module name: promiseRejectionIsError
Paths:

projectname/node_modules/react-native-stripe-api/node_modules/react-native/Libraries/promiseRejectionIsError.js collides with

projectname/node_modules/react-native/Libraries/promiseRejectionIsError.js

Problem: This package react-native-stripe-api seems to be installing another react and react-native module which conflict with the over all project modules.

I think the reason for this is because a specific version of react and react-native modules are defined as a dependency in the react-native-stripe-api/package.json:

  "dependencies": {
    "babel-polyfill": "6.9.1",
    "react": "15.1.0",
    "react-native": "0.27.2"
  },

It seems like these should be removed.

Could someone with more knowledge about npm confirm this is actually the correct way of defining node dependencies. And the appropriate solution to resolve the problem.

like image 247
Shivam Sinha Avatar asked Aug 01 '16 01:08

Shivam Sinha


1 Answers

Your assessment is correct

Could someone with more knowledge about npm confirm this is actually the correct way of defining node dependencies.

They should reference react as a peerDependencies

And the appropriate solution to resolve the problem.

Quickfix: Delete the extra react version

Longfix: Submit a pull request with react as a peer dependency

like image 171
Kyle Finley Avatar answered Oct 13 '22 21:10

Kyle Finley