To install and use NPM packages, we first need to install Node.js and NPM on our computer (in my case a Mac).
I’ve found that although the Node.js website includes an installer, using Homebrew is a better way to install Node and NPM on a Mac. Choosing the Homebrew route means you don’t have to install using
sudo (or non-sudo but with complicated workarounds) which is great because it presents less risk of things going wrong later down the line. It also means you don’t need to mess around with your system
Most importantly, it makes removing or updating Node really easy.
The whole process (after you have XCode and Homebrew installed) should only take you a few minutes.
Just open your Terminal app and type
brew install node.
Updating Node and NPM #
First, check whether or not Homebrew has the latest version of Node. In your Terminal type
Then, to Upgrade Node type:
brew upgrade node.
Uninstalling Node and NPM #
Uninstalling is as easy as running
brew uninstall node.
This post was based on information from an excellent article on Treehouse.