---
title: "npm ERR! ERESOLVE unable to resolve dependency tree"
description: "npm stops with ERESOLVE when two packages want incompatible versions of a peer dependency. Learn how to read the error and fix it with upgrades, overrides or legacy peer deps."
url: https://www.danny.engineering/answer/nodejs/npm-err-eresolve-unable-to-resolve-dependency-tree
author: Danny
published: 2026-11-27T00:00:00.000Z
updated: 2026-11-27T18:57:00.000Z
tags: ["Node.js"]
---

# npm ERR! ERESOLVE unable to resolve dependency tree

## The short answer


One of your packages declares a peer dependency, usually something like React or ESLint, at a version range that does not match the version you have installed. Since npm 7, npm installs peer dependencies for you and refuses to continue when the ranges conflict. The best fix is to upgrade the package that is out of date. If you cannot, pin the shared version with `overrides`, or fall back to `--legacy-peer-deps`.


```bash
# See who needs what
npm explain react

# Last resort: skip automatic peer dependency installs
npm install --legacy-peer-deps
```


## Why it happens


A peer dependency is a package that a library expects you to provide, rather than one it installs for itself. A React component library, for example, lists `react` as a peer so that your app and the library share one copy.


npm 6 only warned about peer conflicts. npm 7 and later treat them as part of the dependency tree and install them automatically, so a conflict becomes a hard error. The message has a pattern worth reading slowly (recent npm versions print `npm error` instead of `npm ERR!`):


```bash
npm ERR! Found: react@19.2.0
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^17.0.0 || ^18.0.0" from some-date-picker@4.1.0
```


"Found" is what you have. "Could not resolve" names the package with the strict peer range. Here the date picker has not declared support for React 19 yet.


## How to fix it


### Upgrade the package with the old peer range


Check whether a newer release of that package supports your version. This is the real fix, because the maintainers have tested it.


```bash
npm view some-date-picker peerDependencies
npm install some-date-picker@latest
```


If no release supports it yet, check the project's issues. Often a beta or a known-good workaround exists.


### Pin the version with overrides


If you have checked that the package works with your version, tell npm to use your version everywhere with `overrides` in `package.json` (npm 8.3 and later). The `$react` value means "the version in my own dependencies".


```json
{
  "dependencies": {
    "react": "^19.2.0",
    "some-date-picker": "^4.1.0"
  },
  "overrides": {
    "some-date-picker": {
      "react": "$react"
    }
  }
}
```


Scoping the override to one package, as above, is safer than overriding `react` for the whole tree. Delete `node_modules` and `package-lock.json` only if the install still uses the old resolution, then run `npm install` again.


### Use --legacy-peer-deps


This restores npm 6 behaviour: peer dependencies are not installed or checked. It works, but it hides every peer conflict, not just this one. If your project needs it, record it in `.npmrc` so everyone on the team and CI installs the same way.


```bash
echo "legacy-peer-deps=true" >> .npmrc
```


### Avoid --force


`npm install --force` also gets past the error, but it can install conflicting copies and change other parts of the tree unpredictably. Prefer the options above.


## Common pitfalls

- Running `--legacy-peer-deps` locally but not in CI, so the build fails with the same error later. Put it in `.npmrc` if you use it.
- Deleting the lock file as a first step. It throws away every pinned version, not only the broken one.
- Overriding a peer to a major version the package truly does not support. The install succeeds and the app fails at runtime.
- Ignoring the error in a fresh `create-*` project. It usually means a template is behind the latest framework release, and an older framework version may be the better choice.

## Related reading

- [npm docs: overrides](https://docs.npmjs.com/cli/configuring-npm/package-json#overrides)
- [npm docs: npm install](https://docs.npmjs.com/cli/commands/npm-install)
