npm 安装react-router-dom 报错

蒙胤
2023-12-01

执行 npm install --save react-router-dom

报错:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: react-xxx@0.1.0
npm ERR! Found: less@4.1.2
npm ERR! node_modules/less
npm ERR!   dev less@"^4.1.2" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! node_modules/less-loader
npm ERR!   less-loader@"5.0.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\50638\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\50638\AppData\Local\npm-cache\_logs\2022-03-16T01_18_11_204Z-debug-0.log

经检查发现,npm 版本过高导致。

使用  npm -v
现有版本 8.3.1

解决:

降低npm版本

npm install npm@6.14.10 -g

然后再次安装router-dom  就成功了

 类似资料: