Webpack "ERESOLVE could not resolve" peer dependency at install before build in CI
Before Webpack ever runs, npm ci fails because a loader or plugin declares a peer dependency on a Webpack version that conflicts with the one in your tree. npm 7+ enforces peer ranges strictly, so the install aborts with ERESOLVE.
What this error means
The install step fails with "npm error code ERESOLVE", "Could not resolve dependency: peer webpack@... ", and a conflict between a loader/plugin and your Webpack version. The build never starts.
npm error code ERESOLVE
npm error Could not resolve dependency:
npm error peer webpack@"^4.0.0" from babel-loader@8.2.5
npm error Conflicting peer dependency: webpack@4.46.0Common causes
A loader/plugin peer range excludes your Webpack
A loader pinned to webpack@^4 cannot coexist with webpack@5; npm 7+ refuses to build an inconsistent tree.
A mixed-major dependency bump
Webpack was upgraded but a loader or plugin was not, leaving the peer ranges incompatible.
How to fix it
Upgrade the loader/plugin to match Webpack
- Read which package's peer range conflicts.
- Install a version of that package whose peer range includes your Webpack.
- Commit the updated lockfile so CI installs cleanly.
npm install babel-loader@9 webpack@5
npm ciUse --legacy-peer-deps only as a stopgap
If you cannot upgrade immediately, this skips peer enforcement, but the underlying mismatch should still be fixed.
npm ci --legacy-peer-depsHow to prevent it
- Upgrade Webpack and its loaders/plugins together.
- Commit a lockfile that resolves cleanly under npm 7+.
- Treat ERESOLVE as a real conflict, not just noise to override.