npm ERESOLVE unable to resolve dependency tree: how to fix it
Why npm stops with ERESOLVE unable to resolve dependency tree, how to read the output, the real fixes, and why npm ci fails when the lockfile drifts.
You run npm install or npm ci and it stops with npm ERR! ERESOLVE unable to resolve dependency tree. Nothing was installed, and the message talks about peers and ranges. This post explains what the error means, how to read it, and which fixes are safe. It also covers why npm ci refuses to run when package.json and package-lock.json disagree.
In short:
- ERESOLVE means two of your packages ask for incompatible versions of a third one, and that third one has to be a single shared copy.
- npm 7 and later treat peer dependencies as part of the tree, so a conflict stops the install instead of printing a warning.
- The real fix is to move the packages together: bump the companion, or override the stale range and record why.
--legacy-peer-depshides the conflict. It does not resolve it, and it has to be set everywhere the install runs.npm cifails on drift by design. Runnpm installlocally and commit the lockfile.
What the error looks like today
Older npm versions print the prefix npm ERR!, and that is the form most search results show. Current npm prints npm error. I reproduced the conflict on npm 11.13.0 with Node 24 on 2026-11-29. A project asks for React 19 and for @testing-library/react 13.4.0, which still wants React 18:
npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
npm error
npm error While resolving: [email protected]
npm error Found: [email protected]
npm error node_modules/react
npm error react@"^19.0.0" from the root project
npm error
npm error Could not resolve dependency:
npm error peer react@"^18.0.0" from @testing-library/[email protected]
npm error node_modules/@testing-library/react
npm error @testing-library/react@"13.4.0" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry this command with --force or --legacy-peer-deps to accept an incorrect (and potentially broken) dependency resolution.
The same conflict can print a second wording, ERESOLVE could not resolve, with an extra Conflicting peer dependency block. In my runs that form appeared when a node_modules or lockfile already existed. The cause is the same. The Found: and Could not resolve dependency: lines are in both.
What peer dependencies are
A normal dependency is something your package uses privately. npm installs it, and it can sit in its own nested folder with its own version.
A peer dependency is a statement about the host. A plugin, a UI kit or a test helper says: "I work with React ^18, and I expect to use the same copy of React your app uses." The npm docs describe it as a plugin-style relationship and ask authors to keep the range as broad as possible to avoid resolution conflicts. Sharing one copy matters. Two copies of React in one app means two sets of hooks state, and things break in confusing ways.
Peers can be marked optional with peerDependenciesMeta. npm does not install optional peers on its own.
Why npm 7 and later enforce them
Before npm 7, peer dependencies were not installed for you. npm 4 to 6 printed a warning if a peer range was not met and carried on. The GitHub blog post announcing npm 7 lists automatic peer installation as a new feature, and the same post says it can break some workflows.
npm RFC 0025 gives the reasoning. Users treated the warning as a bug, some maintainers dropped peer dependencies to silence it, and the installer could build trees that broke peer requirements. The RFC wanted peers to be "a requirement for package tree validity". So the install now fails when peers cannot be placed in the tree without a conflict. The npm docs say as much for npm install: the tool refuses until you resolve it.
The current npm docs add a detail. By default, conflicting peers deep in the tree are resolved from the nearest non-peer dependency, and npm prints a warning. Only conflicts it cannot place stop the install. --strict-peer-deps turns even the warnings into failures.
Reading the output line by line
Take the output above.
While resolving: [email protected]names the package whose dependencies npm was working through when it hit the problem. Here it is your root project.Found: [email protected]is what npm already decided to put in the tree, and the lines below show why: your ownpackage.jsonasked for^19.0.0. Read the indented chain from the bottom up to see who asked for it.Could not resolve dependency:starts the package that disagrees.peer react@"^18.0.0" from @testing-library/[email protected]means that package declares a peer range that the found version does not satisfy.Conflicting peer dependency:(only in the second wording) shows the version npm would have needed to satisfy the peer, and who asked for it.Fix the upstream dependency conflict...offers--forceand--legacy-peer-deps. Treat that line as a description of two risks, not as the next command to run.For a full report see: ...eresolve-report.txtpoints at a longer version with the same chain. It is worth opening when the chain is long.
The conflict is two incompatible ranges on one shared package. npm cannot pick a version that satisfies both.
The real fixes
1. Bump the companions together
Most of the time the packages that disagree are a family: a framework, its type definitions, and its plugins. Look for a newer release of the stale package whose peer range includes your version. In the example, a newer @testing-library/react accepts React 19. Update both in one commit and run npm install so the lockfile changes with them.
If there is no newer release, check the package's issue tracker.
2. Override the stale range, with a note
Sometimes the package works fine with your version and only its declared range is behind. In that case, override it in your root package.json. The npm docs say overrides are read only from the root file, and they accept a nested form that scopes the change to one parent:
{
"dependencies": {
"react": "^19.0.0",
"react-dom": "^19.0.0",
"@testing-library/react": "13.4.0"
},
"overrides": {
"@testing-library/react": {
"react": "$react",
"react-dom": "$react-dom"
}
}
}
$react means "use the same spec my own react dependency uses". The docs require this form, or an exact match, when you override something you also depend on directly. A different spec raises EOVERRIDE. I ran this exact file on npm 11.13.0 and the install succeeded, with one deduped React 19.3.1 under both packages.
An override is a promise that you tested the combination. Run your suite, and record in the commit message why it exists and when to remove it. Remove it when the package catches up.
3. Group the packages in your update bot
This is the fix for the bot-opened PR that fails. Renovate and Dependabot open one PR per package by default. If React and its plugin each need the other's new version, neither PR can pass on its own.
Grouping makes them move together in one PR, which gives the install a chance to see both new versions. This is my reading of how grouping helps. Neither bot's docs promise it for peer conflicts, and Dependabot's docs do not mention peers.
For Renovate, all updates with the same groupName go into one branch and one PR. Use matchPackageNames inside packageRules:
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:recommended"],
"packageRules": [
{
"groupName": "react",
"matchPackageNames": [
"react",
"react-dom",
"@types/react",
"@types/react-dom"
]
}
]
}
Renovate also ships group presets. group:react groups React with its @types packages, and group:recommended extends many of the single-framework presets. Check which presets your config already pulls in before you write a rule that overlaps them. matchPackageNames accepts exact names, globs such as @angular/**, and regexes written between slashes.
For Dependabot, put a groups block under the npm entry in .github/dependabot.yml. patterns takes names and * wildcards:
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
groups:
react:
patterns:
- "react"
- "react-dom"
- "@types/react"
- "@types/react-dom"
Leave out update-types if you want major bumps in the group. Without it, the group takes all semver levels. If you write update-types: ["minor", "patch"], as GitHub's own Angular example does, majors still arrive as separate PRs, and that is where peer conflicts usually come from. A dependency that matches more than one group goes into the first one it matches, and anything matching no group still gets its own PR.
4. When --legacy-peer-deps is a trap
The npm docs describe legacy-peer-deps as making npm ignore peerDependencies entirely when it builds the tree, as npm 3 to 6 did. They also say it is not recommended, because the peer contract that other packages rely on is no longer enforced.
Here is what that looks like in practice. I installed react@^18.3.1 next to react-dom@^19.0.0 with the flag:
$ npm install --legacy-peer-deps
added 5 packages, and audited 6 packages in 10s
The tree held React 18.3.1 and React DOM 19.3.1, and React DOM 19.3.1 declares a peer on React ^19.3.1. That pairing is what the error was warning about. It installed anyway, and the failure moves from install time to run time.
The second problem is that the flag is a setting, not a fix. The next plain npm install in my test failed with ERESOLVE again, and so did npm ci. Your laptop, CI, the Docker build and your update bot all need the same flag, usually through a committed .npmrc containing legacy-peer-deps=true. A bot that does not read it opens red PRs.
It has a narrow legitimate use: a package you cannot change whose range is wrong, while you wait for an upstream release. Prefer an override scoped to that package, because it touches one edge and the flag turns off checking for the whole tree. --force is wider still. The docs list it among settings that remove safety checks, including allowing conflicting peers in the root project, and tell you not to use it unless you know what it will do.
Lockfile drift and why npm ci fails
package-lock.json records the exact tree npm built, with versions, sources and integrity hashes, so later installs can rebuild the same tree. The docs say to commit it. npm ci is the CI-oriented command that installs from it.
npm ci does not repair anything. The docs say it exits with an error if the lock does not match package.json, and that it never writes to either file. I added a dependency to package.json without updating the lock:
npm error code EUSAGE
npm error
npm error `npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing.
npm error
npm error Missing: [email protected] from lock file
Changing a range so a locked version no longer satisfies it gives the other form: Invalid: lock file's [email protected] does not satisfy [email protected].
npm ci is a check followed by an install. If the check fails, nothing is changed and the job is red.
Common causes are a hand edit of package.json, a bad merge of the lockfile, and a bot rebase. The fix is the same each time: run npm install on the branch, read the diff to the lockfile, and commit it. Renovate's npm docs suggest one workaround when npm ci fails over an invalid lock file: add npmInstallTwice to postUpdateOptions, which runs npm install twice.
How pnpm and Yarn differ
pnpm. autoInstallPeers defaults to true, which installs missing required peers at the highest version that satisfies the range. When two packages need incompatible peer ranges, pnpm installs none and prints a warning. strictPeerDependencies is off by default, so a missing or invalid peer is a warning, not a failure, until you turn it on. peerDependencyRules.allowedVersions silences a warning for a range, but the pnpm docs mark it deprecated and recommend overrides with :peer. In CI, --frozen-lockfile is on when a lockfile exists. It fails if pnpm-lock.yaml and the manifest are out of sync, and --no-frozen-lockfile allows updates.
Yarn (Berry). Yarn's resolutions field forces a version and accepts parent paths such as webpack/memory-fs. It works only in the root manifest. packageExtensions in .yarnrc.yml patches a third-party package's missing or wrong dependency and peer metadata. A peer marked optional: true in peerDependenciesMeta stops the warning. enableImmutableInstalls makes Yarn refuse to change the lockfile, and the docs say it is on by default in CI.
The default is the main difference: npm stops on a peer conflict, while pnpm warns.
Where Patchlit fits
Patchlit is a GitHub App that reads the failing CI logs of a red Dependabot or Renovate PR and pushes a small fix to the same branch. Your CI decides whether it worked.
It cannot fix the problems in this post. Its fix loop only edits files and cannot run commands, so it cannot regenerate a lockfile or bump a companion package to clear an ERESOLVE. (A separate merge-conflict tool, switched on per PR, can regenerate package-lock.json; the fix loop cannot.) When that is the failure, it says so on the PR and leaves it to you. A grouping config like the ones above prevents that class of failure better than any fix after the fact. See how it works for the full loop, why red bump PRs happen for the other causes, and security for what it refuses to do.
FAQ
What does "npm ERR! ERESOLVE unable to resolve dependency tree" mean?
Two or more of your packages need different versions of a package that must be shared, usually through a peer dependency. npm 7 and later stop instead of warning. The Found: and Could not resolve dependency: lines name the two sides.
Should I use --legacy-peer-deps or --force?
Not as your first move. --legacy-peer-deps makes npm ignore peers and hides a real mismatch. --force removes more safety checks. Try bumping the companion or a scoped override first, and use the flag only as a short, documented stopgap.
Why does npm ci fail when npm install works?
npm install can change the lockfile to match package.json. npm ci will not. If the two disagree, npm ci exits with EUSAGE. Run npm install locally and commit the new lockfile.
What does the overrides field do in package.json?
It replaces the version of a package elsewhere in your tree. It is read only from the root package.json, can be scoped to one parent package, and uses $name to reuse the spec of a direct dependency.
Does pnpm or Yarn have the same ERESOLVE error?
No. ERESOLVE is an npm error code. pnpm warns by default and fails only with strictPeerDependencies. Yarn offers resolutions, packageExtensions and peerDependenciesMeta.
How do I stop Renovate or Dependabot opening PRs that hit ERESOLVE?
Group the packages that depend on each other, using a groupName rule in Renovate or a groups entry in Dependabot, and include major updates in the group.
Sources
- npm docs, package.json: peerDependencies, peerDependenciesMeta and overrides
- npm docs, npm ci
- npm docs, npm install
- npm docs, config: legacy-peer-deps, strict-peer-deps, force
- npm docs, package-lock.json
- GitHub Blog, Presenting v7.0.0 of the npm CLI
- npm RFC 0025, Install peer dependencies
- npm CLI issue #7509
- Renovate docs, Configuration options, group presets and npm manager
- GitHub docs, Optimizing PR creation for version updates and Dependabot options reference
- pnpm docs, peer dependency settings and pnpm install
- Yarn docs, manifest and .yarnrc.yml
- Own test runs on npm 11.13.0 and Node 24.16.0, 2026-11-29 (all error output above, the override example and the legacy-peer-deps behaviour)
Tags: npm, dependencies, renovate, dependabot, ci