Overview of globally installed npm packages

Written on March 18, 2015

Whenever I ask myself “Wait, what npm packages do I have installed globally?“ I find myself baffled to remember the exact command syntax. Everytime.

When you do a simple npm list -g - hence the -g or --global operates npm in global mode - it outputs in fact all globally installed packages, but also each and every of their corresponding dependencies. If you’re like me and have just a few npm packages installed this will result in a very long list and isn’t quite what I’d call an overview.

The magic argument doing the trick is --depth=0 and instead of searching for it one more time, I’ll put it here. For my own convenience and maybe for yours as well.

npm list -g --depth=0

An alternative to get an overview of globally installed npm packages is ls `npm root -g`, but that won’t return the respective package versions. That’s why I prefer the command above.

Martin Buberl

Purveyor of Internet duct tape.
If you'd like to get in touch, feel free to shout @martinbuberl.