Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

npm says an override conflicts with a direct dependency

Errornpm error code EOVERRIDE

Short answer

npm refuses an override for a package you also depend on directly, unless both specs are exactly the same. Fix it by writing the override as a $ reference to your own dependency, or by scoping the override under the parent package that pulls the nested copy, so the root dependency stays untouched.

  • Applies to npm 10, Node.js 22
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Compare the two places the package is named: dependencies and overrides in package.json. The specs must be identical, or the override must be scoped.

    grep -n -B2 -A6 'react-error-overlay\|"overrides"' package.json
  2. 2Match what you see, then jump to its fix

    1. 1EOVERRIDE, and the package is in both dependencies and overrides with different version stringsThe override spec differs from the direct dependency specFix
    2. 2The version you want to pin belongs to a nested dependency of a tool such as react-scripts, while your own package.json lists anotherYou only want to change the copy that one tool installsFix

What does the error look like?

  • npm error code EOVERRIDE
  • Override for react-error-overlay@^6.0.9 conflicts with direct dependency

Cause 1 of 2

The override spec differs from the direct dependency spec

1Check

npm accepts an override for a direct dependency only when the override spec exactly matches the dependency spec. A caret in one place and a bare version in the other is a mismatch.

npm pkg get dependencies.react-error-overlay overrides.react-error-overlay

2Fix

Use a $ reference. It takes the spec from your direct dependency, so the two can never drift apart.

{
  "dependencies": {
    "react-error-overlay": "^6.0.9"
  },
  "overrides": {
    "react-error-overlay": "$react-error-overlay"
  }
}

3Verify

The install finishes without EOVERRIDE.

npm install

Confirmed by docs.npmjs.com

Did this fix it?

Cause 2 of 2

You only want to change the copy that one tool installs

1Check

A global override applies to every copy of the package, including your direct one, which is what causes the conflict. Find who needs the nested copy.

npm ls react-error-overlay

2Fix

Nest the override under the parent package, so it applies only when the package appears below that parent. The root dependency is then not overridden.

{
  "overrides": {
    "react-scripts": {
      "react-error-overlay": "6.0.9"
    }
  }
}

3Verify

npm ls lists the installed versions of the package, with the pinned one below the parent.

npm install
npm ls react-error-overlay

Confirmed by docs.npmjs.com

Did this fix it?

How do I stop it coming back?

  • Prefer $ references whenever the overridden package is also a direct dependency.
  • Edit overrides only in the root package.json: npm reads no overrides from installed packages.
  • Run npm ls on the package after every override change.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.