How to get list of globally installed npm packages

In this article, we will learn how to get the list of globally installed npm packages on our computer.

While working with npm package we sometimes have to install some packages globally using -g or -global flag with npm install.

However, with times, we may no longer use some global packages and want to remove them. To do that first we have to find out about the list of global npm packages installed on our computer.

To get the list of all the globally installed npm packages, we can use the command npm list -g. However, depending on the node version, we can use other flags to get the package name and its dependencies.

For node 6 and below

npm list -g --depth 0

npm : stands for the node package manager

list -g : list all the npm packages installed globally

--depth 0 : this flag is used to hide each installed package’s dependencies. To show use --depth 1.

For node 7 and above

npm list -g

// or

npm list -global

In node 7 and above, you don’t have to use the --depth 0 flag because npm list command already hides the dependencies of the installed npm packages by default.

However, if you want to display all the dependencies of the installed global packages, you can run add --all config flag or just run

npm list -g --all

You can also use --depth 1 in node 7 too.

Related Topics:

How To Clear Cache In Npm?

Resolve – Node Unexpected Token Import Error

Scroll to Top