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.

知道如何解释和解决这个问题吗?

npm@7ERESOLVE问题很常见,因为npm 7.x对某些事情比npm 6.x更严格。通常,最简单的解决方案是将--legacy-peer-deps标志传递给npm(例如npm i --legacy-peer-deps(或使用npm@6

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

(提示:使用npm@6不需要卸载npm@7。请使用npx指定npm的版本。例如:npx -p npm@6 npm i --legacy-peer-deps。(

对于npm v7+。这是由于package.json文件中提到的条目缺少依赖项

使用npm i --forcenpm i --legacy-peer-deps来覆盖对等依赖关系。

最新更新