在用npm安装element 是遇到改错误,安装类似的,都可以用这个方法解决,在安装命令后加入--legacy-peer-deps,即可成功

报错信息如下

sh-3.2# npm i element-ui -S
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/vue
npm ERR!   vue@"^3.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vue@"^2.5.17" from [email protected]
npm ERR! node_modules/element-ui
npm ERR!   element-ui@"*" 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 /var/root/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /var/root/.npm/_logs/2022-01-09T05_54_09_364Z-debug.log

加入--legacy-peer-deps 后 执行成功。


sh-3.2# npm i element-ui -S --legacy-peer-deps
npm WARN deprecated [email protected]: core-js@<3.4 is no longer maintained and not recommended for usage due to the number ofissues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even ifnothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.

added 9 packages, and audited 1273 packages in 6s

12 packages are looking for funding
  run `npm fund` for details

69 vulnerabilities (2 low, 57 moderate, 10 high)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.