November 03, 2019
When it comes to global node packages, there are typically three things I want to do:
This post is meant to serve as a reminder for how to do all of these (and avoid future web searches).
The easiest way to get a picture of what’s globally installed is:
$ npm list -g --depth=0
The reason we do
--depth=0 is because we rarely want to see the dependencies that our globally installed packages have installed.
The rule of thumb is that if you use the package from the command line, it should be installed globally. In all other cases, even
prettier, they should be installed locally.
To install globally, we can use the following code:
npm install <package-name> -g
Similar to installing a package, uninstalling a package globally just requires the presence of the
npm uninstall <package-name> -g
Remembering these commands is often not worth the mental space they require — particularly early on before they’re muscle memory. Hopefully this proves to be appropriately searchable in order to speed up the information gathering and allow me to get back to the task at hand.
Thanks for reading! My name's Stephen Weiss. I live in Chicago with my wife, Kate, and dog, Finn.
Click here to see the archives of my weeks in review and sign up yourself!