Skip to content
Node.js and Python3 min read

npm ERR! ERESOLVE unable to resolve dependency tree

npm ERR! ERESOLVE unable to resolve dependency tree

Short answer

ERESOLVE means npm couldn't build a dependency tree that satisfies every package's peer dependencies, for example a library that wants React 17 in a React 18 project. The clean fix is to upgrade (or downgrade) the package named in the error; `--legacy-peer-deps` makes the install succeed by ignoring the conflict, at the risk of runtime bugs.

ArabyHost teamLast updated: ShareWhatsAppXLinkedIn
Contents
  1. How to read the error
  2. Causes
  3. How to fix it
  4. When it fails only on the server
  5. Prevention
  6. On ArabyHost

A peer dependency is a package a library expects you to provide, such as React for a React component library. Since npm 7, npm installs peer dependencies itself and refuses to continue when two of them can’t agree on a version. The error text tells you exactly which versions clash.

How to read the error

npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR!   react@"^18.3.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^17.0.0" from [email protected]
  • Found is what your project already uses (React 18).
  • Could not resolve names the package with the conflicting requirement (old-datepicker wants React 17).

The fix is almost always about the package in the second block.

Causes

  • A library hasn’t published a version that supports your framework’s new major version yet.
  • You upgraded the framework (React, Angular, ESLint, TypeScript) but not its plugins.
  • An outdated package pinned in package.json blocks the upgrade.
  • A lock file created with old npm, installed with a newer npm.

How to fix it

  1. Check whether a compatible version exists:

    npm view old-datepicker peerDependencies
    npm view old-datepicker versions --json
  2. Upgrade the conflicting package to a version that accepts your framework version: npm install old-datepicker@latest. This is the real fix.

  3. If no version supports it, replace the library, or keep the framework on the version it supports.

  4. As a deliberate workaround, ignore peer conflicts:

    npm install --legacy-peer-deps

    The trade-off: npm installs a combination the library author didn’t test, which can fail at runtime (for example “invalid hook call” from two copies of React). If you rely on it, add legacy-peer-deps=true to an .npmrc file in the project, so npm ci on your server and in CI resolves the same way.

  5. For one stubborn package, an overrides entry in package.json is more targeted than a global flag:

    "overrides": {
      "old-datepicker": { "react": "$react" }
    }
  6. Avoid --force unless you understand what it overrides.

  7. Verify the tree with npm ls react and run your tests before deploying.

If the install then succeeds but the app can’t load a package, see Cannot find module.

When it fails only on the server

If npm install works on your computer but the same project fails on the server with ERESOLVE, compare the npm versions on both (npm -v) and make sure the server has the same package-lock.json and .npmrc. A lock file created with --legacy-peer-deps can’t be reproduced by a plain npm ci on a machine without that setting, so the server stops at the conflict your computer skipped.

Prevention

  • Upgrade a framework together with its plugins, in a separate branch.
  • Commit package-lock.json and install with npm ci everywhere.
  • Run installs in CI on every change, so conflicts appear before deployment.

On ArabyHost

npm behaves the same on ArabyHost AI/Developer plans as on your computer, with Node.js 20 and 24 available in cPanel’s Setup Node.js App. Commit the same package-lock.json and .npmrc you use locally so installs over SSH resolve identically. For heavy front-end projects such as Next.js, you can install and build in GitHub Actions and deploy the result with automatic deploys from GitHub.

FAQ

What's the difference between --legacy-peer-deps and --force?

`--legacy-peer-deps` ignores peer dependencies, the way npm 6 did. `--force` goes further and overrides conflicts in other places too. Both hide the problem; `--legacy-peer-deps` is the more predictable of the two.

Is it safe to use --legacy-peer-deps?

Often it works, because many libraries declare narrow peer ranges that are stricter than necessary. But nobody tested that combination, so test the affected feature carefully and plan to upgrade the package properly.

Why did this start after upgrading npm?

npm 7 and newer install peer dependencies automatically and stop on conflicts. npm 6 only printed a warning, so old projects that installed fine before can fail now.

Useful? Share it with someone who needs it:WhatsAppXLinkedIn

Read next

Ready to put your idea online?

Fast, isolated hosting, support that understands you, and an AI assistant that fixes problems with you.