How to Install and Manage Node.js via NVM in Windows, Ubuntu and Mac
In this blog, I will explain how to install and manage Node.js via NVM in Windows, Ubuntu and Mac.
What is NVM?
As the name implies, Node Version Manager (NVM) is a tool for managing Node versions on your device. We can have many projects that require a different version of Node.js.You can manage the node js version using NVM.
Install NVM on a Windows machine
Step 1: Download the nvm-setup file for windows
You have to download nvm-setup.exe, from the nvm-windows repository. Download nvm-setup.exe from here
Using this nvm-setup.exe file you will install nvm on your Windows machine.
Step 2: Open Your Terminal and run this command to check whether nvm is successfully installed.
nvm -v // This command will return nvm version
Install NVM on a Mac and Ubuntu machine
Mac and Ubuntu are UNIX-based operating systems so you can install NVM in a similar way.
Step 1: Run the nvm installed
First, make sure you have Curl installed on your machine. If not install curl using this command.
sudo apt update && sudo apt install curl -y // This command will install Curl in your system
Step 2: Install Nvm using this command
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
# or
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
Step 3: Reload the system environment using this command.
This will set the required environment variables to use nvm on the system.
source ~/.bashrc
Step 4: Open Your Terminal and run this command to check whether nvm is successfully installed.
nvm -v
Manage Node Version with help of NVM
Command 1: Install new node version using NVM
nvm install version_name // Using this command you can install the node version
nvm install latest // This command will install latest version of node
nvm install --lts // This command will install the latest LTS release
This command will install a new version of node in your system, make sure you give the correct version name.
Command 2: Available Node versions list
nvm list // This command will show all installed versions of Node in your system.
Command 3: Change Node version
nvm use version_name
nvm use --lts // Use lts version of Node
nvm use newest // User newest installed Node version
Command 4: Uninstall Node version
nvm uninstall version_name
NVM makes it easier to manage multiple versions of Node.js across different projects that require different versions.