How to fix npm ERR! code EOVERRIDE npm ERR! Override not allowed in npm
The EOVERRIDE error occurs when npm's override validation detects a version specification conflict between your overrides and direct dependencies. Use the $ reference syntax or ensure exact version matches to resolve it.
Quick fix
Fixes EOVERRIDE
"dependencies": {
"axios": "^1.6.0"
},
"overrides": {
"axios": "$axios"
}- Use the $ reference syntax
- Ensure exact version match
- Remove conflicting overrides
- Regenerate package-lock.json
"dependencies": {"axios": "^1.6.0"},"overrides": {"axios": "$axios"}npm ERR! code EOVERRIDEnpm ERR! Override not allowed
What this error means
This error indicates that npm's dependency resolver found an invalid override configuration in your package.json. The overrides feature (available in npm 8.3.0+) lets you substitute package versions throughout your dependency tree, but it has strict rules about how overrides interact with direct dependencies. When you have a package listed both as a direct dependency and in your overrides section, npm requires either: (1) the version specifications to match exactly, or (2) the use of the special `$package-name` reference syntax. Any mismatch triggers EOVERRIDE because npm cannot safely determine which version to install. This validation exists to prevent scenarios where your override might accidentally downgrade or conflict with a package you explicitly depend on.
Typical symptoms
- Installation fails with "Override for [package] conflicts with direct dependency"
- npm install and npm ci both fail with EOVERRIDE
- Error appears after adding or modifying the overrides section
- Works on npm 7.x but fails after upgrading to npm 8.3+
- Monorepo projects show errors when workspace dependencies have conflicting overrides
- CI builds fail while local builds might work with cached node_modules
Common causes
- Override version doesn't match the direct dependency version specification
- Using exact version in override while dependency uses range (or vice versa)
- Missing the $ reference syntax for packages that are also direct dependencies
- package-lock.json is out of sync with package.json overrides
- Different npm versions between development and CI environments
- Inherited overrides from a parent workspace conflicting with local dependencies
How to fix "npm ERR! code EOVERRIDE npm ERR! Override not allowed"
For packages that are both direct dependencies and overrides, use the reference syntax:
"dependencies": {
"axios": "^1.6.0"
},
"overrides": {
"axios": "$axios"
}The $axios syntax tells npm to use the version from your dependencies, keeping them automatically synchronized.
If you prefer explicit versions, make sure both specifications are identical:
"devDependencies": {
"react-error-overlay": "^6.0.9"
},
"overrides": {
"react-error-overlay": "^6.0.9"
}The strings must match exactly—^6.0.9 is not the same as 6.0.9.
If the override isn't essential, simply remove it:
"overrides": {
// Remove entries that conflict with direct dependencies
}Overrides are typically only needed for transitive dependencies, not packages you directly control.
Clear the lockfile and node_modules to force npm to recalculate the dependency tree:
rm -rf node_modules package-lock.json
npm installThis resolves issues where the lockfile contains stale override resolutions.
Ensure consistent npm versions across environments:
npm --versionThe overrides feature requires npm 8.3.0 or later. In CI, pin your npm version to avoid surprises:
# GitHub Actions example
- uses: actions/setup-node@v4
with:
node-version: '20'Advanced notes
The EOVERRIDE error is distinct from EOVERRIDECONFLICT—both relate to override validation but trigger under slightly different conditions. EOVERRIDE typically indicates the override itself is not permitted, while EOVERRIDECONFLICT indicates a version mismatch.
In monorepos using npm workspaces, overrides in the root package.json apply to all workspaces. If a workspace has a different version requirement, you may need workspace-specific override handling or restructure your dependencies.
When migrating from Yarn (which uses the resolutions field), note that npm's overrides has different syntax and stricter validation rules. You cannot simply rename the field.
Frequently asked questions
- What does "EOVERRIDE" mean?
- json. 0+) lets you substitute package versions throughout your dependency tree, but it has strict rules about how overrides interact with direct dependencies. When you have a package listed both as a direct dependency and in your overrides section, npm requires either: (1) the version specifications to match exactly, or (2) the use of the special $package-name reference syntax.
- How do I fix "EOVERRIDE"?
- The EOVERRIDE error occurs when npm's override validation detects a version specification conflict between your overrides and direct dependencies. Use the $ reference syntax or ensure exact version matches to resolve it.
- What causes "EOVERRIDE"?
- Override version doesn't match the direct dependency version specification Using exact version in override while dependency uses range (or vice versa) Missing the $ reference syntax for packages that are also direct dependencies
- Is the "EOVERRIDE" error serious?
- It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- 📚npm Official Documentation
- 💬
- 🐙GitHub #5443: npm/cli(GitHub)
- 🔗