How to install node and npm on macOS using Homebrew

What I ❤️ about NodeJS/NPM is that they both just work on any platform I happen to be currently coding, and this comes without extra effort on my behalf.

How to install NodeJs (simple)

The most straightforward way to install NodeJs and npm is to head over to the official page and download one of the installers.

Plain and simple. Just like that.

How to install NodeJs (my way)

Although I like simple, there are times when I prefer to tweak my environment just enough, so it better fits into my preferred daily workflow.

Meet Homebrew

The missing package manager for macOS
Homebrew installs the stuff you need that Apple didn’t.

The way I understand it, Homebrew takes care of finding, downloading and installing stuff on my Mac.

To get things going, open a Terminal and type in the following:

$ brew install node

Voilà!

Why go this way anyway?

The main reason which brought me to using this approach, is that the default NodeJs setup requires sudo to run certain commands. There are of course ways to configure it so it doesn’t need extra privileges but I don’t appreciate googling the exact “spell” every time I want to set things up.

Another important reason is that I like to keep both NodeJs and NPM up to date. With Homebrew, all it takes is a single command and I get all my installed applications and tools updated to their latest versions. Yey! 🚀

Here is a Terminal alias I keep around so that all the updating happens with a single word:

alias brewery='brew update && brew upgrade && brew cleanup'

If there is an even simpler way of doing the above, I would love to read about it :).