npm ERR code ERESOLVE npm ERR ERESOLVE unable to resolve dependency tree

45 篇文章 0 订阅

问题

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! Found: webpack@5.11.1
npm ERR! node_modules/webpack
npm ERR!   dev webpack@"4.41.5" from the root project
npm ERR!   peer webpack@">=2" from babel-loader@8.2.2
npm ERR!   node_modules/babel-loader
npm ERR!     dev babel-loader@"^8.0.0" from the root project
npm ERR!   2 more (copy-webpack-plugin, css-loader)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! dev mini-css-extract-plugin@"^0.9.0" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: webpack@4.44.2
npm ERR! node_modules/webpack
npm ERR!   peer webpack@"^4.4.0" from mini-css-extract-plugin@0.9.0
npm ERR!   node_modules/mini-css-extract-plugin
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.

原因

ERESOLVEnpm@7有关的问题很常见,因为npm7.x对某些事情比npm6.x更严格。通常,最简单的解决方法是将--legacy-peer-deps标志传递给npm(e.g.,npm i --legacy-peer-deps),或者使用npm@6

如果这不能立即起作用,也许可以先删除node_modulespackage-lock.json。它们将被重新创建。

解决方案

降级npm到6版本

使用npx指定npm的版本

npx -p npm@6 npm i --legacy-peer-deps
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
当你在使用npm安装依赖时,如果出现"npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree"的错误信息,它表示npm无法解析依赖树。这通常是由于依赖关系冲突造成的。解决这个问题的方法有两种:修复依赖关系冲突或重新执行npm install命令。 修复依赖关系冲突的方法是,你可以尝试使用--force或--legacy-peer-deps选项,这样可以接受不正确的(可能被破坏的)依赖解析。但是需要注意,这可能会导致其他问题,所以在使用这些选项之前,请确保你已经了解了它们可能带来的潜在影响。 另外,有时候这个错误可能与eslint版本不兼容有关。你可以尝试通过更新eslint或相关的插件来解决这个问题。例如,根据错误提示 "peerDependencies WARNING eslint-plugin-vue@^5.2.3 requires a peer of eslint@^5.0.0" ,你可以尝试更新eslint和eslint-plugin-vue的版本,确保它们符合要求。 总结起来,当出现"npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree"的错误信息时,你可以尝试修复依赖关系冲突或重新执行npm install命令,并根据错误提示更新相关依赖的版本。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree](https://blog.csdn.net/yqx_123/article/details/118787849)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *3* [npm install报错peerDependencies WARNING eslint-plugin-vue@^5.2.3 requires a peer of eslint@^5.0.0 ...](https://download.csdn.net/download/weixin_38693311/14040615)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值