Error Knowledge Base npm ERESOLVE

npm ERR! code ERESOLVE

npm failed with ERESOLVE because it could not build a dependency tree that satisfies the requested versions and peer dependency constraints.

Affected versions: npm v7.0.0 and newer (most common).

Fix it fast

Most likely: Two packages require incompatible peer dependency versions, so npm cannot build one valid dependency tree.

1. Confirm this is your error
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
2. Check the cause
npm ls
npm explain <package>
npm view <package>@<version> peerDependencies --json
npm pkg get dependencies
npm pkg get devDependencies
3. Apply the safe fix
# Align the conflicting package and peer dependency versions, then install again.
npm install <package>@<compatible-version>
npm install <peer-package>@<compatible-version>
npm install

# In workspaces, make the shared peer dependency version consistent from the workspace root.
4. Verify it works
npm ls
npm test
Don't use unsafe shortcuts
  • Do not make --legacy-peer-deps or --force the permanent fix, they can install a tree that breaks at runtime.
  • Do not change unrelated dependencies before reading the first conflicting peer pair in npm's output.
  • Do not upgrade one workspace package without aligning the peer dependency versions used by the rest of the repo.

What Broke in the Dependency Graph

This is npm refusing to continue with a dependency graph that does not make sense. The important detail is which versions or peer requirements disagree, not just the final error code.

Repair the dependency graph

Read the first conflicting peer dependency pair in the npm output (it usually names the exact packages and versions).

Prefer fixing the versions (upgrade/downgrade) so peer ranges line up.

As a temporary unblock, use npm install --legacy-peer-deps (skips peer resolution) or npm install --force (may produce a broken runtime).

If you use workspaces, ensure all workspace packages agree on peer dependency versions.

Why Resolution Broke

Usually this comes down to two dependencies require incompatible versions of the same peer dependency, a package declares a peer dependency range that does not match your installed version, or lockfile drift or partial upgrades left the tree inconsistent.

Prove the Graph Is Clean Again

Run npm ls and ensure the dependency tree is consistent, and run your test/build command to confirm runtime behavior is correct.

Manual dependency inspection

Inspect peer dependencies:npm view <pkg>@<version> peerDependencies

If you must keep multiple versions, consider isolating via separate packages/workspaces.

How npm resolves dependencies

npm resolves dependencies by combining semver ranges into a single tree. Peer dependencies add constraints that must be satisfied by the parent project. When constraints cannot be satisfied, npm throws ERESOLVE with the conflicting packages.

Keep the Dependency Graph Healthy

To prevent this, avoid partial dependency upgrades across a monorepo, pin dependency versions and keep lockfiles committed, and prefer libraries with accurate peer dependency ranges.

Docs and source code

github.com/npm/cli/blob/417daa72b09c5129e7390cd12743ef31bf3ddb83/workspaces/arborist/lib/arborist/build-ideal-tree.js

Open-source npm CLI code reference tied to this error code. - GitHub

    const curNode = node.resolve(edge.name)
    const current = curNode.explain()
    return {
      code: 'ERESOLVE',
      current,
      // it SHOULD be impossible to get here without a current node in place,
      // but this at least gives us something report on when bugs creep into

Need help or found a mistake? Contact RepoFlow support for questions.

Join our mailing list