raineorshine / npm-check-updates

Find newer versions of package dependencies than what your package.json allows
Other
9.33k stars 323 forks source link

Updating dependencies fails when an override is specified #1332

Open ErikBrendel opened 12 months ago

ErikBrendel commented 12 months ago

Steps to Reproduce

{
  "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.

raineorshine commented 12 months ago

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

in-in commented 3 months ago

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