2016-08-01 71 views
4

當我安裝特定的NPM包,我的反應本地項目,並嘗試運行它,我得到以下錯誤:陣營本地複製模塊命名衝突

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 

問題:這個包react-native-stripe-api似乎要安裝其他反應以及與所有項目模塊衝突的反應原生模塊。

我想這樣做的原因是因爲特定版本的反應和應對本地模塊被定義爲反應母語條紋-API /的package.json的依賴:

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

似乎像這些應該被刪除。

能否有人對npm有更多的瞭解確認這實際上是定義節點依賴關係的正確方法。並解決問題的適當解決方案。

回答

5

你的評價是正確的

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

他們應該引用react作爲peerDependencies

And the appropriate solution to resolve the problem.

的QuickFix:刪除多餘的反應版本

Longfix:Submit a pull request有反應作爲peer dependency

0

您應該刪除node_modules文件夾,然後執行npm cache clean,確保有你的項目的根文件夾下的任何臨時緩存文件或文件夾(如react-native-packager-cache-81b2c446等),然後重新執行npm install