2015-10-07 43 views
5

我正在嘗試安裝react-router,但出現以下錯誤。react-router peerDependencies error

$ npm install react-router 
npm WARN peerDependencies The peer dependency [email protected] included from react-router will no 
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency 
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly. 
npm ERR! Windows_NT 6.3.9600 
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "react-router" 
npm ERR! node v0.12.7 
npm ERR! npm v2.11.3 
npm ERR! code EPEERINVALID 

npm ERR! peerinvalid The package react does not satisfy its siblings' peerDependencies requirements! 
npm ERR! peerinvalid Peer [email protected] wants [email protected]^0.14.0-rc1 
npm ERR! peerinvalid Peer [email protected] wants [email protected] 
npm ERR! peerinvalid Peer [email protected] wants [email protected]>=0.13 

npm ERR! Please include the following file with any support request: 
npm ERR!  C:\ReactApps\good start\npm-debug.log 

node-modulesreact中的package.json表明我使用:

"version": "0.14.0-rc1", 

我應該安裝一個早期版本?看來0.13.x可能是更好的支持版本?

如果是這樣的話,我怎麼安裝而不會搞亂我現在的項目?


使用

npm install npm -g 

後我輸入npm -v,看到在我的項目的版本仍然是2.11.13。 我想,這可能是新公共管理的本地版本,所以我輸入:

npm install npm 

希望得到本地更新的最新版本,但仍然得到了2.11.13當我檢查的版本。

comp-asus XXX64 /c/ReactApps/goodRouter/goodrouter (master) 
$ npm -v 
2.11.3 

comp-asus XXX64 /c/ReactApps/goodRouter/goodrouter (master) 
$ npm install react-router 
npm WARN peerDependencies The peer dependency [email protected] included from react-router will no 
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency 
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly. 
npm ERR! Windows_NT 6.3.9600 
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "react-router" 
npm ERR! node v0.12.7 
npm ERR! npm v2.11.3 
npm ERR! code EPEERINVALID 

npm ERR! peerinvalid The package react does not satisfy its siblings' peerDependencies requirements! 
npm ERR! peerinvalid Peer [email protected] wants [email protected] 

npm ERR! Please include the following file with any support request: 
npm ERR!  C:\ReactApps\goodRouter\goodrouter\npm-debug.log 

全球時檢查我可以看到它的更新:

$ npm list -g --depth=0 
C:\Users\Roger\AppData\Roaming\npm 

    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] invalid 
    ├── [email protected] 
    └── [email protected] 

但如何在項目中使用的全球版本?

所以問題仍然存在,但我相信你讓我走上正軌。


$ where npm 
C:\Program Files\nodejs\npm 
C:\Program Files\nodejs\npm.cmd 
C:\Users\Roger\AppData\Roaming\npm\npm 
C:\Users\Roger\AppData\Roaming\npm\npm.cmd 

所以我應該刪除其中的一個?

回答

18

這是[email protected]中解決的主要問題之一。詳情請參閱https://github.com/npm/npm/issues/6565

更新npm是做正確的事:

$ npm install npm -g 
+0

謝謝!如果可以,請參閱更新。我沒有足夠的代表+1,但我非常感謝你。 – RogerDore

+0

@RogerDore你是否在使用某種工具來管理Node版本,比如'nvm'? – eush77

+0

我不熟悉管理Node版本的工具。我現在會查找nvm。 – RogerDore