Vue项目踩坑之Vue-router安装报错

1,902 阅读1分钟

Vue-router插件安装时出现code ERESOLVE报错

PS D:\前端开发\Project\app> npm install vue-router
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! While resolving: app@0.1.0
npm ERR! Found: vue@2.6.14
npm ERR! node_modules/vue
npm ERR!   vue@"^2.6.11" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer vue@"^3.0.0" from vue-router@4.0.12
npm ERR! node_modules/vue-router
npm ERR!   vue-router@"*" 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\91000\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\91000\AppData\Local\npm-cache\_logs\2022-02-09T13_28_06_554Z-debug-0.log

报错原因是 npm版本过高

解决办法

安装低版本的npm

npm install npm@6.14.10 -g

这样会直接下载此版本的npm并自动删除以前的版本和配置