下面是我的错误的详细信息:我的节点版本是16.13.0,npm是8.12.1。
PS D:\ShowCase> npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: uglifyjs-webpack-plugin@2.2.0
npm ERR! Found: webpack@5.51.1
npm ERR! node_modules/webpack
npm ERR! dev webpack@"^5.47.1" from the root project
npm ERR! peer webpack@"4.x.x || 5.x.x" from @webpack-cli/configtest@1.0.4
npm ERR! node_modules/@webpack-cli/configtest
npm ERR! @webpack-cli/configtest@"^1.0.4" from webpack-cli@4.8.0
npm ERR! node_modules/webpack-cli
npm ERR! dev webpack-cli@"^4.7.2" from the root project
npm ERR! 3 more (@webpack-cli/configtest, @webpack-cli/info, @webpack-cli/serve)
npm ERR! 8 more (babel-loader, css-loader, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer webpack@"^4.0.0" from uglifyjs-webpack-plugin@2.2.0
npm ERR! node_modules/uglifyjs-webpack-plugin
npm ERR! dev uglifyjs-webpack-plugin@"^2.2.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: webpack@4.46.0
npm ERR! node_modules/webpack
npm ERR! peer webpack@"^4.0.0" from uglifyjs-webpack-plugin@2.2.0
npm ERR! node_modules/uglifyjs-webpack-plugin
npm ERR! dev uglifyjs-webpack-plugin@"^2.2.0" 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.如果有人遇到过同样的问题,请告诉我。提前谢谢。
发布于 2022-06-04 08:48:05
uglifyjs-webpack-plugin将与Webpack 4合作,但不会与Webpack 5合作。因为这个插件不是Webpack 5的,所以你最好把Webpack的等级从5降到4。如果你想特别使用babel-minify-webpack-plugin或terser-webpack-plugin等插件来最小化javascript代码,可以尝试其他插件来缩小javascript。
您可以检查uglifyjs-webpack-plugin的上一次稳定版本是3年前,并且没有对Webpack 5的开发支持。
https://stackoverflow.com/questions/72489808
复制相似问题