Error Knowledge Base NPM ERESOLVE

npm ERR! code ERESOLVE

npm could not resolve a compatible dependency tree (often peer dependency conflicts).

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

What This Error Means

npm could not resolve a compatible dependency tree (often peer dependency conflicts).

How to Fix It

  1. Read the first conflicting peer dependency pair in the npm output (it usually names the exact packages and versions).
  2. Prefer fixing the versions (upgrade/downgrade) so peer ranges line up.
  3. As a temporary unblock, use npm install --legacy-peer-deps (skips peer resolution) or npm install --force (may produce a broken runtime).
  4. If you use workspaces, ensure all workspace packages agree on peer dependency versions.

Why It Happens

  • Two dependencies require incompatible versions of the same peer dependency.
  • A package declares a peer dependency range that does not match your installed version.
  • Lockfile drift or partial upgrades left the tree inconsistent.

How to Verify

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

Manual dependency inspection

  1. Inspect peer dependencies: npm view <pkg>@<version> peerDependencies.
  2. If you must keep multiple versions, consider isolating via separate packages/workspaces.

Common CLI Output

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree

How npm resolves dependencies

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

Prevention Tips

  • Avoid partial dependency upgrades across a monorepo.
  • Pin dependency versions and keep lockfiles committed.
  • Prefer libraries with accurate peer dependency ranges.

Where This Can Be Triggered

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