【Node】npm i --legacy-peer-deps,解决依赖冲突问题
🍖 前言
npm i --legacy-peer-deps,解决依赖冲突问题
🎶 一、问题描述
node执行安装指令时出现报错,如下:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: mf-turbinemonitor2@0.0.0
npm ERR! Found: stylelint@15.4.0
npm ERR! node_modules/stylelint
npm ERR! dev stylelint@“^15.4.0” from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer stylelint@“>= 11.x < 15” from stylelint-config-prettier@9.0.5
npm ERR! node_modules/stylelint-config-prettier
npm ERR! dev stylelint-config-prettier@“^9.0.5” 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!
npm ERR! For a full report see:
npm ERR! C:\Users\zhang\AppData\Local\npm-cache_logs\2024-04-03T09_53_27_294Z-eresolve-report.txt
npm ERR! A complete log of this run can be found in: C:\Users\zhang\AppData\Local\npm-cache_logs\2024-04-03T09_53_27_294Z-debug-0.log
✨二、代码展示
代码如下:
npm i --legacy-peer-deps
🏀三、运行结果
控制台输出展示:
🏆四、知识点提示
知识点1:
- –legacy-peer-deps 标志允许在 npm 7 中使用旧版的 peer dependency 解析算法,这相当于回退到 npm 6 之前的解析方式
- 在从 npm 6 迁移到 npm 7 时,一些包可能还未更新以适应新的 peer dependencies 规则,此时可以使用 --legacy-peer-deps 保证依赖安装顺利进行
原文地址:https://blog.csdn.net/qq_47481604/article/details/140608889
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!