Unable to install Webpack 5 ERESOLVE

Viewed 130

I have a project in the works with 96 vulnerabilities (85 moderate, 11 high), and most of them seem to be related to having an older version of webpack. However, when I try and update to the current version, this happens.

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: webpack@5.38.1
npm ERR! node_modules/webpack
npm ERR!   dev webpack@"5.38.1" from the root project
npm ERR!   peer webpack@">=4.43.0 <6.0.0" from @pmmmwh/react-refresh-webpack-plugin@0.4.3
npm ERR!   node_modules/@pmmmwh/react-refresh-webpack-plugin
npm ERR!     @pmmmwh/react-refresh-webpack-plugin@"0.4.3" from react-scripts@4.0.3
npm ERR!     node_modules/react-scripts
npm ERR!       react-scripts@"4.0.3" from the root project
npm ERR!   12 more (babel-loader, css-loader, eslint-webpack-plugin, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer webpack@"^4.0.0" from optimize-css-assets-webpack-plugin@5.0.4
npm ERR! node_modules/optimize-css-assets-webpack-plugin
npm ERR!   optimize-css-assets-webpack-plugin@"5.0.4" from react-scripts@4.0.3
npm ERR!   node_modules/react-scripts
npm ERR!     react-scripts@"4.0.3" 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.

Does anyone know how to fix the dependency conflict without using legacy-peer-deps?

0 Answers
Related