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

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>

You can also install specific version:

npm install -g [email protected]

You will have to either use this script or do them one by one it seems.

This global update is a known breaking point. Here is the reference to this issue. They seem to have closed it without addressing the issue

Tags:

Npm