Why `npm update -g` is not updating my global packages to the latest version?

Viewed 20772

I'm following steps from updating global packages, so I executed npm outdated -g --depth=0 and got:

Package     Current  Wanted  Latest  Location
typescript    2.2.2   2.2.2   2.4.1

Then, I executed npm update -g, but I still got the same output from npm outdated -g --depth=0.

Executing npm list -g --depth=0 also confirms that the typescript package has not been updated to 2.4.1:

+-- bower@1.8.0
+-- gulp@3.9.1
+-- typescript@2.2.2
`-- typings@2.1.1

What am I missing?

4 Answers

You can also install specific version:

npm install -g typescript@2.4.1

As of now, there is no one simple command that does this.

You can use the following steps instead to find outdated packages and update them one by one.

  1. Determining which global packages need updating: To see which global packages need to be updated, on the command line, run:

    npm outdated -g --depth=0
    
  2. Updating a single global package: To update a single global package, on the command line, run:

    npm update -g <package_name>
    

To automatically update all global packages to the 'Latest' version in a single command:

npx npm-check --global --update-all

That will update all global packages to the 'Latest' version. More information is available about npm-check, including the ability to perform an interactive update, 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>
Related