The BIG frustration of using NVM to manage Node versions

I recently started messing around with Node and some projects – some being my very own projects and others belonging to the good people of the open-source community.

I think most would agree, that the main frustration is always the Node compatibility when trying out other developers projects:

The engine “node” is incompatible with this module. Expected version “>=8.9.0”. Got “8.0.0”

After a bit of digging around on the internet, I came across Node Version Manager (NVM): https://github.com/nvm-sh/nvm

I instantly fell in love. NVM allows you to switch between or manage multiple active node.js versions easily with just a few lines in your command prompt.

Installation

I am not going to dive into the installation on this post. The repository has the installation instructions, so you can head over there and install NVM: https://github.com/nvm-sh/nvm

Using NVM

If installed correctly, the nvm command is available anywhere in your terminal.

Install Multiple Versions of Node.js
One of the most important parts of nvm is, installing different versions of Node.js. For this, nvm provides the nvm install command. You can install specific versions by running this command followed by the version you want. For example:

Switch Between Versions of Node.js
You obviously have to have the desired versions already installed on your local machine. To see which versions are installed on your local machine, you need to type in the following command:

To list all available version available, you use the following command.

You can add or remove any of the modules you installed on your local machine as desired using the available nvm [options][arguments].

Switching to a specific version is as easy as:

You can also set your very own desired default version by simply using the following command:

What To Take Home

You obviously noticed that I used version numbers in my example. The versions are not set in stone. It’s best to check what’s available and in most cases switch to the latest LTS (Long Term Support) version recommended by the Node.JS foundation. The recommendation can be found on their homepage: https://nodejs.org/en/

Additionally, please head over to the NVM repository page frequently to check to familiarise yourself with how the NVM bash script works and how you can use it to improve your development productivity.

Code, music, craft beer and traveling to remote areas are the only real languages I speak.

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