NodeJS npm i导致许多ERESOLVE问题

qjp7pelc  于 2023-01-20  发布在  Node.js
关注(0)|答案(2)|浏览(168)

我在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。
你知道如何解释和解决这个问题吗?

qcbq4gxm

qcbq4gxm1#

npm@7ERESOLVE问题很常见,因为npm 7.x在某些方面比npm 6.x更严格。通常,最简单的解决方法是将--legacy-peer-deps标志传递给npm(例如npm i --legacy-peer-deps),或者使用npm@6
如果不能立即运行,可以尝试先删除node_modulespackage-lock.json,它们将被重新创建。
(Tip:您无需卸载npm@7即可使用npm@6。请改用npx指定npm的版本。例如:npx -p npm@6 npm i --legacy-peer-deps .)

jchrr9hc

jchrr9hc2#

对于npm v7+。这是由于package.json文件中提到的条目缺少依赖项
使用npm i --forcenpm i --legacy-peer-deps覆盖对等依赖关系。

相关问题