Tips,  Tools

List globally installed npm packages with versions

One command lists every globally installed npm package and its version — useful when migrating globals to yarn or a new machine.

List globally installed npm packages with versions

Now that yarn is all the hype, I am guessing a lot of people would want to reinstall their global packages using yarn. In order to find the package names and versions of globally installed packages all you need to do is:

The command

npm ls -g --depth=0

That prints the global tree with versions and no nested dependencies. Copy the names you care about and reinstall them wherever you are moving next — yarn global, a fresh Node install, or nvm with --reinstall-packages-from.

Thanks for reading! To stay updated on my latest posts and thoughts, follow me on Twitter @masimplo

Subscribe to masimplo.com

Get the latest posts delivered right to your inbox