Nope, I didn’t Misspell NPM — Node Version Manager is it’s Own Handy Dev Tool

NVM — a simple bash script to manage multiple active Node.js versions

Multiple Node Environments are a Pain to Develop In Locally

I’m sure I’m not alone when I tell you that my current development team owns two different UI applications: one built in AngularJS (the old one) and one built in React (the new one). The two work together to serve up a single user experience, while we slowly migrate over the existing screens and functionality from the old, AngularJS application into the new, React application. The end goal is that the React application will one day host the entire application on its own.

I’m sure I’m also not alone when I tell you that the AngularJS application will ONLY run on Node.js version 9 (it crashes and causes weird bugs if it’s not), and our React application needs Node version 10 or above to take advantage of all the ES6 and beyond features.

And you know what? Switching between Node environments for local development is kind of a pain. It’s not easy, it’s something I forget to do frequently (until I have an unexplained issue during development), and frankly, it’s just not the easiest thing to do on a Mac.

This was my lot in life, until a co-worker clued me in to an awesome tool called Node Version Manager (NVM).

NVM is a local development game changer. Let me tell you how.

Node Version Manager

What Is It?

Node Version Manager is exactly what its name says:

[NVM is a] Simple bash script to manage multiple active node.js versions. — NVM, Github

While it doesn’t sound complicated, what NVM can do is awesome. It makes it possible to:

Access every long term support (LTS) version of Node.js from v0.1.14 to the latest version today, which happens to be v.11.10.1 , as I write this,

to the latest version today, which happens to be , as I write this, Download any one of those remote LTS versions of Node locally with a simple command,

Set up aliases to switch between different downloaded versions of Node with ease,

Default to automatically use whichever version of Node.js is specified if a .nvmrc file is present in a repo,

file is present in a repo, And it works with multiple types of shells: Sh, Bash, Zsh, Dash, Ksh, (not Fish though).

As long as you’re fairly comfortable with the command line, you can use NVM.

Setting Up NVM

NVM is relatively easy to set up too — after hearing about its benefits, I was able to use the Github README.md to set it up on my computer in short order.

Step 1: Install NVM

The first step is simplest: just install NVM with the curl or wget command provided in the documentation.

Curl command:

curl -o-

https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

Wget command:

wget -qO-

https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

Step 1.5 Verify NVM in the Command Line

Close out your terminal, open a new window and type:

command -v nvm

If it’s installed you’ll get a message like: