node.js - npm i 导致许多 ERESOLVE 问题
问题描述
我收到此错误npm i
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.
当我将 nodejs 降级到 14.15.4 时,我得到了它,但我实际上可能需要降级 node.js。
知道如何解释这个问题并解决它吗?
解决方案
ERESOLVE
问题npm@7
很常见,因为 npm 7.x 对某些事情比 npm 6.x 更严格。通常,最简单的解决方案是将--legacy-peer-deps
标志传递给npm
(例如,npm i --legacy-peer-deps
)或使用npm@6
。
如果这不能立即起作用,也许先尝试删除node_modules
and package-lock.json
。它们将被重新创建。
npm@7
(提示:使用时不需要卸载npm@6
。使用npx
来指定版本npm
。例如:npx -p npm@6 npm i --legacy-peer-deps
。)
推荐阅读
- python - 如何使用 Python 请求将图像发送到 Strapi?
- ruby-on-rails - Rails 密码重置邮件测试未定义方法“html_safe”错误(使用 Clearance gem)
- node.js - 在 node.js 中合并两个 opus 流
- python - 如何使用 numpy 中的指定索引从 3D 矩阵中获取元素?
- javascript - 定时器完成时需要通知,在下一个间隔之前
- javascript - 如何使用 Gatsby 或 React 功能组件处理从数据库中的异步获取
- python - pd.df.groupby() 永远不会发生的事件 (0%)
- python-3.x - 我的 Python 库在我的目录中的正确位置吗?
- azure - 将大量数据从 Oracle 9i 迁移到 Azure Hyperscale 的最佳方法
- python - 在 2 个模式之间提取文本