NVM To The Rescue

February 26, 2019


Node has become a part of most of our coding lives. But if we are working on latest technologies like React and at the same time working on your legacy code, you might have noticed that you have switch between two versions of Node. For instance, I was working with node v6.10.2 for my company project and node v10.15.0 for my personal learnings. I used to uninstall and install those versions based on my requirements until I found NVM.

NVM - Node Version Manager

NVM stands for “Node Version Manager”. NVM helps us to handle multiple versions of node very easily by giving us the ability to switch between them based on our requirement.

Let us look at the setup

  • Installing nvm

    For installing nvm, head over here and download the latest stable nvm setup file (nvm-setup.zip). At the time of writing this article, the stable version is 1.1.7

    Download the .zip file and extract .exe from it and proceed with installation.

  • Installing nodejs

    We have done with the installation of nvm. Now we have to install our required node versions. For example, if we need latest node version along with v6.10.2, we have to do:

    For istalling latest nodejs version, run

    $ nvm install latest

    For istalling specific version of nodejs, run

    $ nvm install 6.10.2

    restart your Command Prompt.

  • Usage:

    Now we have both the versions of node installed on to our system. To verify which versions are present, run $ nvm list

    which lists down all your versions oresent on your syaytem.

    To switch between versions, just run $ nvm use <node_version_you_want_to_use>. For eg,

    $ nvm use 10.15.0

    We are now switched to Node v10.15.0. To verify, try running

    $ node -v

    that should return you the version we have choosen.

  • That’s all folks ! Now we are good to keep rocking with our coding.

NOTE: One important thing to remember when we are using nvm, the global space of each node version is different. i.e., if you have some node modules installed globally for one version of node, they won’t be accessible to other versions. You have to install them seperately on those versions too.

edit this page on github

Kirankumar Ambati

Written by Kirankumar Ambati who lives and works in Hyderabad. Twitter Linkedin Github