解决npm ERR! code ERESOLVE -npm ERR! ERESOLVE could not resolve

当使用一份vue源码开发项目时,npm install 报错了

npm ERR! code ERESOLVE

npm ERR! ERESOLVE could not resolve

npm ERR!

npm ERR! While resolving: [email protected]

npm ERR! Found: [email protected]

npm ERR! node_modules/webpack

npm ERR! webpack@"^4.0.0" from @vue/[email protected]

npm ERR! node_modules/@vue/cli-plugin-babel

npm ERR! dev @vue/cli-plugin-babel@"4.4.4" from the root project

npm ERR! webpack@"^4.0.0" from @vue/[email protected]

npm ERR! node_modules/@vue/cli-service

npm ERR! dev @vue/cli-service@"4.4.4" from the root project

npm ERR! peer @vue/cli-service@"^3.0.0 || ^4.0.0-0" from @vue/[email protected]

npm ERR! node_modules/@vue/cli-plugin-babel

npm ERR! dev @vue/cli-plugin-babel@"4.4.4" from the root project

npm ERR! 2 more (@vue/cli-plugin-eslint, @vue/cli-plugin-unit-jest)

npm ERR! 2 more (@vue/cli-plugin-eslint, html-webpack-plugin)

npm ERR!

npm ERR! Could not resolve dependency:

npm ERR! dev less-loader@"^11.1.0" from the root project

npm ERR!

npm ERR! Conflicting peer dependency: [email protected]

npm ERR! node_modules/webpack

npm ERR! peer webpack@"^5.0.0" from [email protected]

npm ERR! node_modules/less-loader

npm ERR! dev less-loader@"^11.1.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\63089\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\63089\AppData\Local\npm-cache_logs\2023-08-04T04_52_18_223Z-debug-0.log

出错的原因是

  1. 项目使用了 [email protected]
  2. 项目需要 [email protected],在 @vue/[email protected]@vue/[email protected] 中指定了这个版本。
  3. less-loader 的依赖发生了冲突。项目需要 less-loader@"^11.1.0",但与此冲突的是 [email protected],它需要 less-loader@"^11.1.3"

降低less-loader的版本,解决了

"less-loader": "^7.x.x",

相关推荐
白小白灬6 分钟前
Vue主题色切换实现方案(CSS 变量 + 类名切换)
前端·css·vue.js
江沉晚呤时11 分钟前
.NET Core 中 Swagger 配置详解:常用配置与实战技巧
前端·.netcore
waterHBO25 分钟前
chrome 浏览器插件 myTools, 日常小工具。
前端·chrome
哎呦你好28 分钟前
HTML 颜色全解析:从命名规则到 RGBA/HSL 值,附透明度设置与场景应用指南
前端·css·html
多云的夏天1 小时前
前端:VUE-(0)-环境搭建和helloworld
前端·javascript·vue.js
Dontla1 小时前
BootCDN介绍(Bootstrap主导的前端开源项目免费CDN加速服务)
前端·开源·bootstrap
90后小陈老师1 小时前
WebXR教学 07 项目5 贪吃蛇小游戏
前端·数码相机
欧先生^_^2 小时前
Node.js 源码架构详解
架构·node.js
一口一个橘子2 小时前
[ctfshow web入门] web118
前端·web安全·网络安全
GanGuaGua2 小时前
Vue3:脚手架
前端·javascript·css·vue.js·vue