How to fix npm ERR! code EOVERRIDECONFLICT npm ERR! Override conflicts with existing dependency in npm

npmINTERMEDIATEMEDIUMUpdated Dec 6, 2025ยท 267 views

The EOVERRIDECONFLICT error occurs when your package.json overrides section specifies a version that conflicts with a direct dependency. Fix it by using the $ reference syntax or matching version specifications exactly.

Quick fix

Fixes EOVERRIDECONFLICT

"overrides": {
  "react-error-overlay": "$react-error-overlay"
}
  1. Use the $ reference syntax
  2. Match version specifications exactly
  3. Clear cache and reinstall
  4. Remove unnecessary overrides
npm โ€” error
"overrides": {
"react-error-overlay": "$react-error-overlay"
}
npm ERR! code EOVERRIDECONFLICT
npm ERR! Override conflicts with existing dependency

What this error means

This error means npm detected a conflict between your overrides configuration and a direct dependency in your package.json. The overrides feature (introduced in npm 8.3.0) allows you to replace specific versions of packages in your dependency tree, but npm requires that overrides for direct dependencies must match exactly or use special reference syntax. When you specify an override like `"axios": "^1.2.0"` but your direct dependency says `"axios": "1.2.5"`, npm cannot determine which version specification should take precedence. This validation prevents accidental version mismatches that could lead to runtime errors or security vulnerabilities. The error is npm's way of enforcing intentional, deliberate overrides rather than accidental conflicts that might break your dependency tree.

Typical symptoms

  • npm install fails immediately with EOVERRIDECONFLICT error
  • Error message shows "Override for [package] conflicts with direct dependency"
  • Build pipelines break in CI/CD after dependency updates
  • Error appears after upgrading to npm 8.3.0 or later
  • Occurs when tools like npm-check-updates modify dependencies without updating overrides
  • npm ci fails while npm install with --force might work

Common causes

  1. Override specifies a different version range than the direct dependency (e.g., "^1.2.0" vs "1.2.5")
  2. Direct dependency was updated but the corresponding override was not
  3. Not using the $package-name reference syntax for overriding direct dependencies
  4. Stale package-lock.json containing old override resolutions
  5. Automated dependency update tools modifying dependencies without syncing overrides
  6. Copy-pasting override configurations from other projects without adjustment

How to fix "npm ERR! code EOVERRIDECONFLICT npm ERR! Override conflicts with existing dependency"

1Use the $ reference syntax

The recommended solution is to use npm's reference syntax, which automatically tracks the direct dependency version:

json
"overrides": {
  "react-error-overlay": "$react-error-overlay"
}

This tells npm to use whatever version is specified in your dependencies/devDependencies for this package. The override will automatically stay in sync if you update the dependency later.

2Match version specifications exactly

If you need to specify an explicit version, ensure the override matches the direct dependency exactly:

json
"dependencies": {
  "axios": "^1.2.0"
},
"overrides": {
  "axios": "^1.2.0"
}

Both specifications must be identical strings, not just semantically equivalent versions.

3Clear cache and reinstall

If the conflict persists after fixing package.json, clear your npm cache and reinstall:

bash
rm -rf node_modules package-lock.json
npm cache clean --force
npm install

Stale lockfiles often contain old override resolutions that conflict with updated configurations.

4Remove unnecessary overrides

Review your overrides section and remove any that are no longer needed. Fewer overrides means fewer potential conflict points. Only keep overrides that serve a specific purpose like security patches or compatibility fixes.

5Use --legacy-peer-deps as last resort

If other solutions fail and you need to proceed urgently:

bash
npm install --legacy-peer-deps

Warning: This disables override validation entirely and may result in an inconsistent dependency tree. Only use for temporary debugging, not production builds.

Advanced notes

The overrides feature was introduced in npm 8.3.0 (bundled with Node.js 16.13.0+) to allow developers to replace packages anywhere in the dependency tree. This is particularly useful for security patches in transitive dependencies.

In CI/CD pipelines, use npm ci instead of npm install to ensure reproducible builds from your lockfile. When using dependency update bots like Dependabot or Renovate, configure them to update both dependencies and corresponding overrides together.

For monorepo setups, consider using workspace-level overrides in the root package.json to maintain consistency across packages.

Frequently asked questions

What does "EOVERRIDECONFLICT" mean?
json. 0) allows you to replace specific versions of packages in your dependency tree, but npm requires that overrides for direct dependencies must match exactly or use special reference syntax. 5", npm cannot determine which version specification should take precedence.
How do I fix "EOVERRIDECONFLICT"?
The EOVERRIDECONFLICT error occurs when your package.json overrides section specifies a version that conflicts with a direct dependency. Fix it by using the $ reference syntax or matching version specifications exactly.
What causes "EOVERRIDECONFLICT"?
Override specifies a different version range than the direct dependency (e.g., "^1.2.0" vs "1.2.5") Direct dependency was updated but the corresponding override was not Not using the $package-name reference syntax for overriding direct dependencies
Is the "EOVERRIDECONFLICT" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading