欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 财经 > 创投人物 > 【Node】npm i --legacy-peer-deps,解决依赖冲突问题

【Node】npm i --legacy-peer-deps,解决依赖冲突问题

2024/10/24 21:25:17 来源:https://blog.csdn.net/qq_47481604/article/details/140608889  浏览:    关键词:【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 保证依赖安装顺利进行

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com