If you've ever had problems running a project because you didn't install a compatible version of Node.js, you are not alone. Fortunately, there is a simple solution to this problem.
Node Version Manager (NVM) allows you to install multiple versions of Node.js on your computer and choose which version to use depending on the project you want to run.
NVM is an open source project that aims to simplify the installation and administration process of Node.js.
What is Node.js?
Popular front-end web frameworks that use Node.js include Angular and React. Remember that Node.js can also be used to develop back-end or full-stack applications. Popular back-end frameworks that use Node.js include Express.js, Meteor.js, Nest.js, and Hapi.js.
Install NVM on Linux
Installing NVM on Linux is pretty straightforward. Open your Terminal and run the following command.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | Bash
The above command runs a script that downloads and installs NVM. In addition, a profile for NVM is set in your environment variable. In this case it is .bashrc File as you can see from the installation output below.
The environment variable file is in one of the following locations: ~ / .bash_profile, ~ / .zshrc, ~ / .profile, or ~ / .bashrc depending on the Linux distribution you are using.
Check the installation
Note: Before you can check whether the installation was successful, close your current terminal and open a new terminal window. Alternatively, you can open another terminal window by pressing Ctrl + Alt + T. on the keyboard.
In the new terminal window, you can verify that NVM has been installed successfully by running the following command.
Command -v nvm
If all went well, the output from the above command will be nvm As shown below.
To check the version of NVM installed on your PC, you can do the following.
Installing Node.js with NVM is very easy. For example, to install the latest version of Node.js, you can run the following command:
NVM installation node
To install a specific version of Node.js, you can run the nvm command in the following format:
Version number of the NVM installation
For example, to install Node.js version 14.15.4:
nvm install 14.15.4
Node.js version 14.15.4 is an LTS version of Node.js.
If you've come this far and given the two commands above, congratulations! You have two different versions of Node.js installed on your PC or server.
Choosing which version of Node.js. to use
If you have multiple versions of Node.js installed, you can easily choose which version of Node.js you want to use. For example, to use the recently installed version 14.15.4, you can run the following command.
nvm use 14.15.4
To see the list of Node.js versions installed on your PC, you can run the following command.
The output of the listing is similar to the following. The currently active version is also highlighted.
To list all versions of Node.js available for installation, you can run:
Uninstalling a version of Node.js through NVM is very easy. For example, to uninstall version 14.15.4 installed above:
Uninstall nvm v14.15.4
Simply enter the following command to learn more about NVM commands or for help:
You can also visit NVM's official GitHub page which is well documented.
Node.js management simplified
This guide shows you how to install Node Version Manager (NVM) to make managing and installing Node.js easier. If you have projects that use different versions of Node.js, NVM is the tool for you. It will just make your life easier.
About the author
(5 articles published)
Mwiza is a professional developer of software and writes extensively on Linux and front-end programming. Some of his interests include history, economics, politics, and enterprise architecture.
By Mwiza Kumwenda
Subscribe to our newsletter
Sign up for our newsletter to receive tech tips, reviews, free e-books, and exclusive offers!
One more step …!
Please confirm your email address in the email we just sent you.