解决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: vue-admin-template@4.4.0

npm ERR! Found: webpack@4.46.0

npm ERR! node_modules/webpack

npm ERR! webpack@"^4.0.0" from @vue/cli-plugin-babel@4.4.4

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/cli-service@4.4.4

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/cli-plugin-babel@4.4.4

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: webpack@5.88.2

npm ERR! node_modules/webpack

npm ERR! peer webpack@"^5.0.0" from less-loader@11.1.3

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. 项目使用了 vue-admin-template@4.4.0
  2. 项目需要 webpack@4.46.0,在 @vue/cli-plugin-babel@4.4.4@vue/cli-service@4.4.4 中指定了这个版本。
  3. less-loader 的依赖发生了冲突。项目需要 less-loader@"^11.1.0",但与此冲突的是 webpack@5.88.2,它需要 less-loader@"^11.1.3"

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

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

相关推荐
Hooray15 分钟前
前端暗黑模式的适配艺术
前端·vue.js·视觉设计
恋猫de小郭15 分钟前
解析华为 DevEco Code 和小米 MiMo Code,都基于 OpenCode ,有什么区别?
android·前端·ios
IT_陈寒17 分钟前
Vue的响应式让我原地裂开,你们也有这情况吗
前端·人工智能·后端
问心无愧051334 分钟前
ctfshow web入门114
android·前端·笔记
晓得迷路了39 分钟前
栗子前端技术周刊第 133 期 - Angular v22、React 编译器 Rust 版、pnpm 11.5...
前端·javascript·css
一个被程序员耽误的厨师41 分钟前
02-架构篇-前端怎么反客为主把AI编排权拿回到自己手里
前端·人工智能·架构
云浪1 小时前
别再让用户干等了:用 Express + SSE 实现《红楼梦》AI 问答实时输出
javascript·后端·node.js
羊羊小栈1 小时前
基于混合检索RAG的食品生产质量问答系统(BGE_BM25_大语言模型)
前端·人工智能·语言模型·自然语言处理·毕业设计·大作业
烤代码的吐司君1 小时前
Redis 服务配置与使用
前端·bootstrap·html
之歆1 小时前
Ajax 基础技术深度解析:XHR 从入门到跨域
前端·ajax·okhttp