npm-check-updates
npm-check-updates copied to clipboard
Updating dependencies fails when an override is specified
- [x] I have searched for similar issues
- [x] I am using the latest version of
npm-check-updates
- [x] I am using
node >= 14.14
Steps to Reproduce
- have a package defined as dependency and as override (useful when some other dependencies have an unnecessary hard constraint and we want to deduplicate the dependency tree)
- use
npx -y npm-check-updates --interactive
and press enter twice (updating this dependency and installing the changes)
{
"name": "example",
"dependencies": {
"typescript": "^5.1.6"
},
"overrides": {
"typescript": "^5.1.6"
}
}
Current behavior
Only the dep is updated, and not the override, leading to this error output:
✔ Choose which packages to update ›
typescript ^5.1.6 → ^5.2.2
✔ Run npm install to install new versions? … yes
Installing dependencies...
npm
ERR! code EOVERRIDE
npm ERR! Override for typescript@^5.2.2 conflicts with direct dependency
Desired behavior
In these cases where the dependency and the override are equal, the dependency and override should be updated in sync, so that the installation then works.
Fixed in v16.14.2
. Thanks!
FYI: In researching the problem, I came across this recommendation in the official npm docs (emphasis mine):
You may not set an override for a package that you directly depend on unless both the dependency and the override itself share the exact same spec. To make this limitation easier to deal with, overrides may also be defined as a reference to a spec for a direct dependency by prefixing the name of the package you wish the version to match with a $.
{
"name": "example",
"dependencies": {
"typescript": "^5.1.6"
},
"overrides": {
"typescript": "$typescript"
}
}
https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides
Unfortunately, the recommendation from the official npm docs does not always work https://github.com/npm/cli/issues/5730
This comment explains in more detail what is happening https://github.com/npm/cli/issues/5730#issuecomment-1627722630