Skip to content
FR
  1. LuzineDebug
  2. JavaScript & Node.js
  3. npm ERR! ERESOLVE unable to resolve dependency t…
JavaScript & Node.js Intermediate ≈ 15 min to fix

Fix "npm ERR! ERESOLVE unable to resolve dependency tree"

Error message
npm ERR! ERESOLVE unable to resolve dependency tree
  • npm error code ERESOLVE
  • npm error ERESOLVE unable to resolve dependency tree
  • npm ERR! ERESOLVE could not resolve
  • npm ERR! Could not resolve dependency: npm ERR! peer react@"^18.0.0" from [email protected]
  • npm ERR! Conflicting peer dependency: [email protected]
In short

npm refuses to install because two packages require incompatible versions of the same dependency, most often a peer dependency (React, ESLint, Angular). The real fix is to update the blocking package or align versions; --legacy-peer-deps is only a workaround.

Be the first to confirm this fix

What this error means

A peer dependency is a library a package uses without bundling it: a React plugin declares for example "peerDependencies": { "react": "^18.0.0" } and relies on your project’s React version. Since npm 7, peer dependencies are installed and checked automatically. If your project uses react@19 and a package only accepts ^18, npm cannot build a tree that satisfies everyone and stops with ERESOLVE. The message shows the version found ("Found:") and the requirement that fails ("Could not resolve dependency:"). Since npm 10, the npm ERR! prefix has become npm error.

Common causes

  1. Major version upgrade: you move to React 19, ESLint 9 or Angular N+1 before a library has widened its peer dependency.
  2. Old or abandoned package: a dependency is no longer maintained and only accepts old versions.
  3. Mixed versions of one family: @angular/core and @angular/router, or ESLint plugins from different major versions.
  4. Project created with npm 6 or --legacy-peer-deps: the conflict already existed but was ignored, and comes back on a fresh install.

Step-by-step fix

  1. Read the conflict

    Scroll up in the output: the "Found:" line gives the installed version (for example [email protected]) and "Could not resolve dependency: peer react@"^18.0.0" from [email protected]" gives the blocking package. The full report is also saved in the eresolve-report.txt file named at the end.

  2. Look for a compatible version of the blocking package

    Check the peer dependencies of the latest version: an update is often enough.

    bash
    npm view some-lib peerDependencies
    npm view some-lib@latest version
    npm install some-lib@latest
  3. Align versions

    If no compatible version exists, pick the main dependency version accepted by everyone (for example stay on React 18 until the library catches up), or replace the abandoned library.

    bash
    npm install react@18 react-dom@18
  4. Force a targeted version with overrides

    If you have checked that the library works with your version, declare it in package.json. $react reuses the React version declared in your dependencies. The workaround only affects that package; then run npm install again.

    json
    {
      "dependencies": {
        "react": "^19.0.0",
        "some-lib": "^2.3.0"
      },
      "overrides": {
        "some-lib": {
          "react": "$react"
        }
      }
    }
  5. Last resort: --legacy-peer-deps

    This option restores npm 6 behavior: peer dependencies are ignored for the whole tree. The install succeeds, but nothing guarantees the packages work together. --force is even more permissive. If you use it, document it and remove it as soon as the library is updated.

    bash
    npm install --legacy-peer-deps
  6. Check the final tree

    After the fix, check that only one version of the shared dependency remains and that no error is reported, then commit package.json and package-lock.json together.

    bash
    npm ls react

Did this fix work for you?

Confirm it in one click: it will rise for the next developers stuck on the same error.

Keep it from coming back

  • Before a major upgrade, check your libraries’ peer dependencies with npm view <package> peerDependencies.
  • Avoid legacy-peer-deps=true in .npmrc: it applies to the whole team and CI and hides future conflicts.
  • Update packages from the same family together (all @angular/*, all ESLint plugins) rather than one by one.

Frequently asked questions

What is the difference between --legacy-peer-deps and --force?

--legacy-peer-deps ignores peer dependencies. --force overrides every conflict and can install several incompatible versions. Both are workarounds to avoid when an update is possible.

Why does the error appear with npm but not with Yarn or pnpm?

Yarn and pnpm report unmet peer dependencies as a warning without blocking the install. The conflict is still there.

Does deleting node_modules and package-lock.json fix ERESOLVE?

Not if the conflict comes from the versions declared in package.json: npm will compute the same tree and fail again. You need to change versions or add an overrides entry.

Useful tools for this error

More JavaScript & Node.js errors

All JavaScript & Node.js errors →