Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not resolve dependency: npm ERR! peer webpack@"^4.0.0" from [email protected]

Here is details of my error: My node version is 16.13.0 and npm is 8.12.1.

PS D:\ShowCase> npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
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/[email protected]
npm ERR!   node_modules/@webpack-cli/configtest
npm ERR!     @webpack-cli/configtest@"^1.0.4" from [email protected]
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 [email protected]
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: [email protected]
npm ERR! node_modules/webpack
npm ERR!   peer webpack@"^4.0.0" from [email protected]
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.

Please let me know if anyone has faced the same problem. Thanks in advance.

like image 655
Anand Gaikwad Avatar asked Sep 10 '25 23:09

Anand Gaikwad


1 Answers

The uglifyjs-webpack-plugin will work fine with Webpack 4 but will not work with Webpack 5. Since this plugin is not scheduled for Webpack 5, You better downgrade Webpack from 5 to 4. Or Try other plugins like babel-minify-webpack-plugin or terser-webpack-plugin to minify javascript if you want to use uglifyjs-webpack-plugin specifically to minimize javascript code.


You can check the last stable release of uglifyjs-webpack-plugin was 3 years ago, and no documented development support for Webpack 5.

like image 178
MORÈ Avatar answered Sep 13 '25 12:09

MORÈ