Node package manager (npm
) provides the ability to install node packages globally in a computer. This is useful when using packages like @angular/cli, @nestjs/cli, @vue/cli, etc. When using the -g
argument with the install command, a package will be installed globally. For example, the below command will install npm
globally.
npm install -g npm
Before proceeding with this article, ensure that you have npm installed. Visit node.js to install npm.
To list globally installed packages, open a terminal or console and enter the below command.
npm list -g
After executing the above command, the list of packages installed globally will be displayed. This list will also include the dependencies for each package. Below is a sample output.

To avoid displaying the dependencies for each package, it is better to use the below command.
npm list -g --depth 0
Below is a sample output.

To list outdated globally installed packages, enter the following command.
npm outdated -g
To update the outdated globally installed packages, enter the following command.
npm update -g
Note that the above command will only update the packages to the latest minor version. A major version tends to introduce breaking changes, for example, when react-tables was upgraded from version 6 to 7.
In order to upgrade every globally installed package to the latest version (including latest major version), install the following package globally.
npm install -g npm-check-updates
To update all globally installed packages to the latest version, enter the following command.
ncu -g -u
To uninstall a global package, use the below command.
npm uninstall -g <package_name>
Summary
With the use of npm
and npm-check-updates
, it is very easy to manage globally installed packages.
Further information on npm-check-updates
can be found at the following link:
Software versions used in this article
- node v12.18.2
- npm v6.14.6
- ncu v7.0.2