How to View All Global Packages in npm


Let’s get a quick introduction to global packages.

Local vs Global Packages

Installing a local package looks like this:

npm install <package-name>

The package will be placed in the node_modules folder in the current directory.

Installing a global package looks like this:

npm install -g <package-name>

The package will be placed with all the other global packages on your system.

If you need to run a command from a package in any directory, then you might want to consider installing it as a global package.

Some examples may include:

  • create-react-app
  • react-native-cli
  • gatsby-cli
  • nodemon
  • vue-cli

View Global Packages

To view where on your system all the global packages live, run:

npm ls -g | head -1

To view all main packages (and not the sub-packages installed along the way), run:

npm ls -g --depth 0

You can remove --depth 0 if you want to view every global package.