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即可解决。

相关推荐
zl0_00_0几秒前
xss-lab
前端·网络·xss
爱上你家菜包7 分钟前
Electron一小时快速上手
前端·javascript·electron
陈琦鹏8 分钟前
Vue3+Vite开发Electron桌面端问题记录
前端·javascript·electron
狼性书生2 小时前
uniapp vue3实现的一款数字动画调节器件,支持长按、单点操作,提供丝滑的增减动画效果
前端·vue.js·微信小程序·小程序·uni-app
Jelena157795857922 小时前
爬虫获取微店商品快递费 item_feeAPI 接口的完整指南
开发语言·前端·爬虫
总是学不会.2 小时前
从“记住我”到 Web 认证:Cookie、JWT 和 Session 的故事
java·前端·后端·开发
白水先森3 小时前
ArcGIS Pro技巧实战:高效矢量化天地图地表覆盖图
经验分享·arcgis·arcgispro
xinran_Yi3 小时前
XSS-labs靶场通关
前端·xss
前端代码仔3 小时前
JS继承的几种实现方式
前端·javascript
巅峰赛2000分以下是巅峰3 小时前
buuctf.web 64-96
前端