为什么“ npm install”告诉我“没有安装,您必须自己安装对等依赖项:”?

时间:2019-08-12 22:18:13

标签: javascript node.js reactjs ionic-framework npm

我正在尝试使react / redux / ionic应用程序正常工作。

运行npm install时出现错误:

>`enter code here`npm install
npm WARN @ionic/react@0.0.5 requires a peer of react-router@^4.3.1 but none is installed. You must install peer dependencies yourself.
npm WARN @ionic/react@0.0.5 requires a peer of react-router-dom@^4.3.1 but none is installed. You must install peer dependencies yourself.

但是当我查看package.json时,看起来好像应该安装react-routerreact-router-dom一样:

"@ionic/react": "0.0.5",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-redux": "^7.0.3",
"react-router": "^5.0.0",
"react-router-dom": "^5.0.0",
"react-scripts": "3.0.1",
"redux": "^4.0.1",

关于可能发生的事情的任何想法吗?

2 个答案:

答案 0 :(得分:0)

查看警告消息提供的版本 您需要卸载较新的版本,然后重新安装专门提供的版本 卸载:

npm uninstall react-router react-router-dom

(作为健全性检查,请查看package.json确认已删除) 然后安装警告中提供的专门需要的版本

npm i -S react-router@^4.3.1 react-router-dom@^4.3.1

答案 1 :(得分:0)

只需尝试:

npm缓存清理-f npm install