How to fix npm ERR! code ERESOLVE npm ERR! Found: package@version npm ERR! Could not resolve dependency: npm ERR! package@version from the root project in npm

npmINTERMEDIATEMEDIUMUpdated Dec 6, 2025· 152 views

The ERESOLVE error occurs when npm 7+ encounters conflicting peer dependency requirements. Use --legacy-peer-deps for a quick fix, or resolve the underlying version conflicts for a permanent solution.

Quick fix

Fixes npm ERR! code ERESOLVE npm ERR! Found: package@version npm ERR! Could not resolve dependency: npm ERR! package@version from the root project

# For single install
npm install --legacy-peer-deps

# For specific package
npm install package-name --legacy-peer-deps
  1. Use --legacy-peer-deps flag (quick fix)
  2. Make legacy-peer-deps permanent
  3. Use --force for aggressive resolution
  4. Clean reinstall to reset state
npm — error
# For single install
npm install --legacy-peer-deps
# For specific package
npm install package-name --legacy-peer-deps
npm ERR! code ERESOLVE
npm ERR! Found: package@version
npm ERR! Could not resolve dependency:
npm ERR! package@version from the root project

What this error means

npm 7 introduced strict peer dependency resolution that fails when packages declare incompatible peer dependency requirements. This is a significant change from npm 6, which only warned about peer dependency conflicts. The error occurs when npm cannot find a version of a package that satisfies all peer dependency constraints in your dependency tree. For example, if package A requires React 17 and package B requires React 18, npm cannot satisfy both requirements simultaneously and throws ERESOLVE.

Typical symptoms

  • npm install fails immediately with ERESOLVE error code
  • Error displays specific package names and conflicting version ranges
  • Works on npm 6 but fails on npm 7, 8, or 9
  • CI/CD pipelines fail during dependency installation
  • Adding a new package triggers conflicts with existing dependencies
  • Major framework upgrades (React, Angular, Vue) cause widespread conflicts

Common causes

  1. Package requires older version of a framework you have upgraded
  2. Two packages have mutually exclusive peer dependency requirements
  3. npm 7+ strict peer dependency enforcement (npm 6 only warned)
  4. Package not yet updated for latest framework version
  5. Misaligned package.json and package-lock.json after manual edits
  6. Installing packages built for different major versions of a framework

How to fix "npm ERR! code ERESOLVE npm ERR! Found: package@version npm ERR! Could not resolve dependency: npm ERR! package@version from the root project"

1Use --legacy-peer-deps flag (quick fix)

Revert to npm 6 peer dependency behavior:

bash
# For single install
npm install --legacy-peer-deps

# For specific package
npm install package-name --legacy-peer-deps

This ignores peer dependency conflicts and proceeds with installation.

2Make legacy-peer-deps permanent

Add to .npmrc for project-wide setting:

bash
# Create or edit .npmrc in project root
echo "legacy-peer-deps=true" >> .npmrc

Now all npm install commands will use legacy resolution.

3Use --force for aggressive resolution

Bypass all safety checks (use with caution):

bash
npm install --force

Warning: This may install incompatible versions that cause runtime errors.

4Clean reinstall to reset state

Sometimes conflicts arise from corrupted lockfile state:

bash
# Remove cached dependency state
rm -rf node_modules package-lock.json

# Reinstall fresh
npm install

# Or with legacy peer deps
npm install --legacy-peer-deps
5Identify and resolve specific conflicts

For a proper fix, identify the conflicting packages:

bash
# See outdated packages
npm outdated

# Check what versions are available
npm view package-name versions

# Update the conflicting package
npm install package-name@latest

Update packages to versions compatible with your framework version.

6Use overrides to force versions (npm 8.3+)

Force specific versions using package.json overrides:

json
{
  "overrides": {
    "react": "^18.2.0"
  }
}

This tells npm to use React 18 everywhere, regardless of peer dependency declarations.

7Consider switching to Yarn

Yarn often handles peer dependencies more gracefully:

bash
# Install Yarn
npm install -g yarn

# Remove npm artifacts
rm -rf node_modules package-lock.json

# Install with Yarn
yarn install

Yarn uses a different resolution algorithm that may avoid the conflict.

Advanced notes

Using --legacy-peer-deps or --force masks underlying compatibility issues. Packages installed may conflict at runtime, causing duplicate package instances, incorrect behavior, or hard-to-debug errors. For production applications, investigate and resolve the root cause.

Common scenarios requiring this fix:
- Upgrading React 17 → 18 with packages not yet supporting React 18
- Angular major version upgrades
- Using beta/release candidate versions of frameworks
- Older packages no longer maintained

For CI/CD, add legacy-peer-deps=true to .npmrc in the repository, or modify install commands. GitHub Actions example:

yaml
- run: npm ci --legacy-peer-deps

Frequently asked questions

What does "npm ERR! code ERESOLVE npm ERR! Found: package@version npm ERR! Could" mean?
npm 7 introduced strict peer dependency resolution that fails when packages declare incompatible peer dependency requirements. This is a significant change from npm 6, which only warned about peer dependency conflicts. The error occurs when npm cannot find a version of a package that satisfies all peer dependency constraints in your dependency tree.
How do I fix "npm ERR! code ERESOLVE npm ERR! Found: package@version npm ERR! Could"?
The ERESOLVE error occurs when npm 7+ encounters conflicting peer dependency requirements. Use --legacy-peer-deps for a quick fix, or resolve the underlying version conflicts for a permanent solution.
What causes "npm ERR! code ERESOLVE npm ERR! Found: package@version npm ERR! Could"?
Package requires older version of a framework you have upgraded Two packages have mutually exclusive peer dependency requirements npm 7+ strict peer dependency enforcement (npm 6 only warned)
Is the "npm ERR! code ERESOLVE npm ERR! Found: package@version npm ERR! Could" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading