Steven Lu
Steven Lu

Reputation: 43427

npm outdated global packages: How to actually update a package?

❯ npm outdated -g
Package              Current  Wanted  Latest  Location
eslint                3.11.1  3.11.1  3.15.0
eslint-plugin-react    3.0.0   6.9.0   6.9.0
flow-bin              0.35.0  0.39.0  0.39.0
grunt-cli             0.1.13   1.2.0   1.2.0
gulp                   3.9.0   3.9.1   3.9.1
jshint                 2.8.0   2.9.4   2.9.4
npm                    3.8.6   4.3.0   4.2.0
uglify-js              2.7.0   2.7.5   2.7.5

Wondering why my eslint won't update. npm upgrade -g -dd eslint shows me

npm verb outdated not updating eslint because it's currently at the maximum version that matches its specified semver range

Which led me to try outdated, but either way, global package.json isn't a thing that exists. So why am I limited to 3.11??

According to npmjs doc,

If there's no available semver range (i.e. you're running npm outdated --global, or the package isn't included in package.json), then wanted shows the currently-installed version.

This simply doesn't make any sense.

Upvotes: 5

Views: 5480

Answers (2)

Andrew D. Bond
Andrew D. Bond

Reputation: 1280

To update global packages to the 'Latest' version:

npx npm-check --global --update

That will update global packages to the 'Latest' version*. More information is available about npm-check, including the ability to update without prompting, exclude packages, etc.


Conversely, npm update -g only updates global packages to the 'Wanted' version shown by npm outdated --global, as globally installed packages are treated as if they are installed with a caret semver range specified.


Lastly, if you happen to want to update (install) a package to a version other than 'Latest' or 'Wanted': npm install --global <pkg>@<version>

Upvotes: 1

Steven Lu
Steven Lu

Reputation: 43427

Following the de-facto workflow of npm, we remove and reinstall the package.

npm remove -g eslint && npm install -g eslint

npm, why are you so bad?

Upvotes: 2

Related Questions