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
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- Use --legacy-peer-deps flag (quick fix)
- Make legacy-peer-deps permanent
- Use --force for aggressive resolution
- Clean reinstall to reset state
# For single installnpm install --legacy-peer-deps# For specific packagenpm install package-name --legacy-peer-depsnpm ERR! code ERESOLVEnpm ERR! Found: package@versionnpm 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
- 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)
- Package not yet updated for latest framework version
- Misaligned package.json and package-lock.json after manual edits
- 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"
Revert to npm 6 peer dependency behavior:
# For single install
npm install --legacy-peer-deps
# For specific package
npm install package-name --legacy-peer-depsThis ignores peer dependency conflicts and proceeds with installation.
Add to .npmrc for project-wide setting:
# Create or edit .npmrc in project root
echo "legacy-peer-deps=true" >> .npmrcNow all npm install commands will use legacy resolution.
Bypass all safety checks (use with caution):
npm install --forceWarning: This may install incompatible versions that cause runtime errors.
Sometimes conflicts arise from corrupted lockfile state:
# Remove cached dependency state
rm -rf node_modules package-lock.json
# Reinstall fresh
npm install
# Or with legacy peer deps
npm install --legacy-peer-depsFor a proper fix, identify the conflicting packages:
# See outdated packages
npm outdated
# Check what versions are available
npm view package-name versions
# Update the conflicting package
npm install package-name@latestUpdate packages to versions compatible with your framework version.
Force specific versions using package.json overrides:
{
"overrides": {
"react": "^18.2.0"
}
}This tells npm to use React 18 everywhere, regardless of peer dependency declarations.
Yarn often handles peer dependencies more gracefully:
# Install Yarn
npm install -g yarn
# Remove npm artifacts
rm -rf node_modules package-lock.json
# Install with Yarn
yarn installYarn 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:
- run: npm ci --legacy-peer-depsFrequently 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.