Fixing npm EOVERRIDE Errors with overrides
If you see npm error code EOVERRIDE, your overrides in package.json specifies a different version for a package that you also list directly in dependencies (or devDependencies). Change the overrides value to "$" + package name, such as "ms": "$ms". This makes the override refer to the same spec as the direct dependency, and the error goes away.
The official documentation gives replacing a dependency with a known security problem as one use case for overrides. If you try to align the version of a transitive dependency (a package that another dependency uses) and the same package is also a direct dependency, you get this error. I reproduced the error in a test environment, confirmed the message, and confirmed that the fix removes it.
The test environment was Ubuntu 24.04. I mainly tested with Node.js 22.23.5 (npm 10.9.9). For comparison, I also tested with npm 11.19.1, which comes with Node.js 24.22.3: npm install with the error and with the $ms fix, and npm ci with the error. I did not test Windows, macOS, yarn, pnpm, npm 9 or earlier, or projects with workspaces.
- 1. package.json that triggers the error
- 2. A direct dependency can only be overridden with the same spec
- 3. Fix 1: reference the direct dependency with
$ms - 4. Fix 2: make both values the same string
- 5. If you do not want to touch the direct dependency, nest the override
- 6. npm ci shows a different message
- 7. The same message in npm 11
package.json that triggers the error
I created a project that directly depends on ms with ^2.1.3 and also installs debug@2.6.9. debug@2.6.9 depends on ms@2.0.0, so without overrides, two versions of ms are installed.
$ npm ls ms
eo-demo@1.0.0 /path/to/eo-demo
+-- debug@2.6.9
| `-- ms@2.0.0
`-- ms@2.1.3
(In the output in this article, I replaced the project path of the test environment with /path/to/eo-demo and the log file path with ~/.npm/_logs.)
To make the ms under debug also 2.1.3, I write "ms": "2.1.3" in overrides.
{
"name": "eo-demo",
"version": "1.0.0",
"dependencies": {
"debug": "2.6.9",
"ms": "^2.1.3"
},
"overrides": {
"ms": "2.1.3"
}
}
When I ran npm install in this state, it failed with exit code 1 and printed the following. Neither node_modules nor package-lock.json was created.
$ npm install
npm error code EOVERRIDE
npm error Override for ms@^2.1.3 conflicts with direct dependency
npm error A complete log of this run can be found in: ~/.npm/_logs/2026-11-26T05_04_31_772Z-debug-0.log
The ms@^2.1.3 on the second line is the spec written in dependencies. The message means that the override for ms@^2.1.3 conflicts with the direct dependency.
A direct dependency can only be overridden with the same spec
The overrides section of the package.json documentation says that you cannot set an override for a directly depended-on package unless the dependency and the override have exactly the same spec. It then says that, to make this restriction easier to work with, you can reference the spec of a direct dependency by using the package name with a $ prefix.
In the npm 10.9.9 source, for each root dependency, npm compared the spec after applying the override with the spec written in package.json as strings. If they differed and the override did not start with $, it raised EOVERRIDE.
Because the comparison is a string comparison, the error occurs even when the ranges overlap. "ms": "~2.1.3" and "ms": "2.x" both include 2.1.3, but their strings differ from ^2.1.3, so they stopped with the same message.
Fix 1: reference the direct dependency with $ms
Set the override value to "$ms". This is the form the documentation lists as the best practice (BEST).
{
"dependencies": {
"debug": "2.6.9",
"ms": "^2.1.3"
},
"overrides": {
"ms": "$ms"
}
}
npm install finished with exit code 0 and no error. The ms under debug also became 2.1.3, the same version as the direct dependency.
$ npm install
added 2 packages, and audited 3 packages in 271ms
found 0 vulnerabilities
$ npm ls ms
eo-demo@1.0.0 /path/to/eo-demo
+-- debug@2.6.9
| `-- ms@2.1.3 deduped
`-- ms@2.1.3 overridden
node_modules/debug/node_modules was not created, so there was no separate copy under debug.
Fix 2: make both values the same string
Without $, the error also went away when I made the overrides and dependencies specs the same string. I tried the following two options. In both, npm install finished with exit code 0, and the result of npm ls ms was the same as with Fix 1.
- Set
overridesto"ms": "^2.1.3"(matchdependencies) - Set
dependenciesto"ms": "2.1.3"(matchoverrides)
With this form, when you change the version later, you must change both places to the same string. If you change only one, you get the same mismatch as in the first example, and the same error appears. With "$ms", you do not need to write the same string in overrides.
If you do not want to touch the direct dependency, nest the override
If you want to keep the direct ms as it is and override only the ms under debug, write the override inside debug.
{
"dependencies": {
"debug": "2.6.9",
"ms": "^2.1.3"
},
"overrides": {
"debug": {
"ms": "2.1.3"
}
}
}
In this case, the spec differs from the direct dependency's ^2.1.3, but there was no error, and npm install finished with exit code 0. In npm ls ms, the debug line is marked overridden, and the ms under it is ms@2.1.3 deduped.
On the other hand, when I wrote the override for the package itself with ., as in "ms": { ".": "2.1.3" }, I got the same EOVERRIDE as with "ms": "2.1.3". When I moved ms to devDependencies instead of dependencies, it also stopped with the same message.
npm ci shows a different message
When I changed overrides to a conflicting spec in a state where a lock file existed and ran npm ci, the output did not show EOVERRIDE. Instead, it looked as if the lock file were missing. package-lock.json existed, and the exit code was 1.
$ npm ci
npm error code EUSAGE
npm error
npm error The `npm ci` command can only install with an existing package-lock.json or
npm error npm-shrinkwrap.json with lockfileVersion >= 1. Run an install with npm@5 or
npm error later to generate a package-lock.json file, then try again.
(使い方の一覧の行は省略)
npm error A complete log of this run can be found in: ~/.npm/_logs/2026-11-26T05_04_36_222Z-debug-0.log
The actual cause was in the log file whose location is shown on the last line. The log contained this line:
14 verbose loadVirtual Error: Override for ms@^2.1.3 conflicts with direct dependency
In the npm 10.9.9 source, npm ci replaced any failure while reading the lock file with this usage error, regardless of the cause. npm 11.19.1 printed the same statement, and its log contained the same Override for ms@^2.1.3 conflicts with direct dependency. If you see this message even though a lock file exists, and the loadVirtual line in the log contains Override for … conflicts with direct dependency, check your overrides. After I changed overrides back to "$ms", npm ci finished with exit code 0.
In the same state, npm ls ms printed npm error code EOVERRIDE as is.
The same message in npm 11
With "ms": "2.1.3" still in place, I switched to npm 11.19.1 (in the test environment I changed the PATH) and ran npm install. It printed the same message as npm 10.9.9 (I omitted the log line).
$ npm install
npm error code EOVERRIDE
npm error Override for ms@^2.1.3 conflicts with direct dependency
After I changed it to "ms": "$ms", it finished with exit code 0, and the ms under debug also showed ms@2.1.3 deduped. With npm 11.19.1, npm ls ms did not mark the root ms line as overridden.





