Managing node version in your system for different node projects

Photo by Ferenc Almasi on Unsplash

Often times we come across different javascript libraries and dependencies which are compatible with different versions of NodeJS platform. For example, you might a AngularJS app which required specific version of Node while you might also be working on another project with VueJS stack which again depends on some version of Node. As long as these projects along with their node module dependencies are compatible with same version of Node we are good. Other-wise, it gives a hard time during compilation.

To get over this problem, we can simply use NVM or Node version manager. This is going to be a very short article to get started.

First you need to install NVM depending on what system you use from here. Once done, you can cross-verify whether it works correctly by checking installed version in bash/shell/cmd

Using nvm version to check current installed version of NVM
NVM version command

Once you have installed it, all we need to do is install specific node version that we require.

Apart from the version we have installed, our system might have other versions already installed as shown in the image below

Using nvm ls command to list all available installed node versions
Using nvm ls command to list all available installed node versions
NVM list command

As highlighted in the image, the first version of Node pointed at with an arrow in green is the current version of Node in use. To switch to another version of Node of our interest, all we need to do is set it using NVM

Using nvm use command to set Node version
Using nvm use command to set Node version
NVM use command

It’s pretty simple to use NVM in your system to maintain and work with different projects compatible or dependent on different version of Node. These are just few of the commands to get started with NVM, you can check more about other available commands on the nvm github repository.

Software developer