How to set up MacOS for Node.js

iTerm2

The very first thing I install on a brand new Mac is iTerm2. I use it instead of the built-in Terminal app.

You can still use MacOS’s Terminal if you want but I recommend using iTerm. It adds a lot of useful features to the basic Terminal app (Split Pane is one of my favourites). Unlike Terminal, iTerm is constantly updated and improved.

To install iTerm, download the package, unzip it and put into your Applications folder.

Homebrew

Next, let’s install Homebrew — “the Missing Package Manager for macOS” as it advertises itself. With Homebrew, we can easily install new software. Just take a look at the list of available packages — chances are whatever you need is there.

Paste this command into the terminal and let the scripts do the rest and install Homebrew on you Mac.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Zsh

Let’s beef up our terminal with zsh. It’s autocomplete feature and the ability to correct spelling mistakes will save you a lot of time.

Install zsh with Brew like so:

brew install zsh

To make zsh your default shell, run this command:

sudo sh -c "echo $(which zsh) >> /etc/shells" && chsh -s $(which zsh)

Oh My Zsh

Let’s beef up our terminal even more with Oh My Zsh! It adds a ton of useful plugins, functions and aliases (shortcuts) into the terminal. And it has themes.

Install Oh My Zsh with this command:

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Once it is done and you are in no rush, take a look at available themes or plugins. Pick the ones you like and make your terminal your own.

NVM

Now we are ready to install Node.js.

I don’t install Node.js directly by downloading the package from the website or via Brew. Sometimes you have to run a project on a specific version of Node and setting up the correct environment can be a painful waste of time.

Luckily, someone created nvm — Node Version Manager. nvm enables us to have multiple versions of Node installed and makes switching between them easy.

Check nvm’s install guide to get the latest version.

Once you done installing, type nvm in the terminal to see what nvm can do. Scroll down to examples to learn how to install a new version of Node or how to switch between them.

Image for post
Image for post

One thing to remember is that global NPM packages are installed per Node version. When you switch between Node versions, you will have to install global packages again (or use--reinstall-packages-from argument for nvm install to migrate packages from one version to another).

IDE

At this point, you have a fully functional Node.js environment on you Mac. You can download any Node project, install the packages and run it locally.

The last thing to complete our Node.js setup on Mac is to install an IDE or text editor for coding. I use Visual Studio Code these days but you can also use Sublime Text or Atom. Pick whichever suits you the best and you are ready to go!

Written by

I write about biotech, learning, computing and futurism | http://conradthegray.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store