npm ERR! ERESOLVE could not resolve

html 复制代码
PS D:\wp\project\newPorject\tyzhhw-mysql\code\tyzhhw_sheshi> npm install
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: mapbox-gl-draw@0.16.0
npm ERR! Found: mapbox-gl@2.5.1
npm ERR! node_modules/mapbox-gl
npm ERR!   mapbox-gl@"^2.5.1" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer mapbox-gl@"^0.27.0 || ^0.28.0" from mapbox-gl-draw@0.16.0
npm ERR! node_modules/mapbox-gl-draw
npm ERR!   mapbox-gl-draw@"^0.16.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: mapbox-gl@0.28.0
npm ERR! node_modules/mapbox-gl
npm ERR!   peer mapbox-gl@"^0.27.0 || ^0.28.0" from mapbox-gl-draw@0.16.0
npm ERR!   node_modules/mapbox-gl-draw
npm ERR!     mapbox-gl-draw@"^0.16.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\admin\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\admin\AppData\Local\npm-cache\_logs\2023-07-27T00_52_56_730Z-debug-0.log

问题产生的原因和如何解决,其实npm已经列在了最后:

html 复制代码
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps

问题原因是依赖冲突导致不能下载依赖包(dependency conflict),

因为npm版本升级(version>7),

npmV7之前的版本遇到依赖冲突会忽视依赖冲突,继续进行安装,

npmV7版本开始不会自动进行忽略,需要用户手动输入命令。

解决的方法就是command with --force,或者--legacy-peer-deps

--force 无视冲突,强制获取远端npm库资源 (覆盖之前)

--legacy-peer-deps 忽视依赖冲突,继续安装(不覆盖之前)

因此输入:npm install --force 或者 npm install --legacy-peer-deps即可解决。

相关推荐
Watermelo6172 分钟前
【前端实战】从 try-catch 回调到链式调用:一种更优雅的 async/await 错误处理方案
前端·javascript·网络·vue.js·算法·vue·用户体验
木易 士心3 分钟前
NestJS 核心揭秘:InstanceWrapper 的艺术与前端缓存新思路
前端·缓存
IT_陈寒6 分钟前
SpringBoot 3.x性能优化实战:这5个配置让你的应用启动速度提升50%
前端·人工智能·后端
奶昔不会射手7 分钟前
css之如何获取祖先元素的宽高
前端·css
serve the people8 分钟前
滑块验证完整实现教程(前端 + 后端 + Nginx 集成)
运维·前端·nginx
yivifu9 分钟前
Excel中Lookup函数实现临界点归入下一个等级的方法
java·前端·excel
Wiktok10 分钟前
Tailwind CSS 自适应相关
前端·css·tailwindcss
LYFlied11 分钟前
【一句话概括】Vue2 和 Vue3 的 diff 算法区别
前端·vue.js·算法·diff
亮子AI15 分钟前
Chrome 和 Edge 生成的 fingerprint 是一样的?
前端·chrome·edge
狼性书生16 分钟前
uniapp实现的时间范围选择器组件
前端·uni-app·vue·组件·插件