How to install Node.js with NVM on Ubuntu and switch between Node versions

How to install Node.js with NVM on Ubuntu and switch between Node versions

NVM (Node Version Manager) is a tool that allows you to install and manage multiple versions of Node. Although it’s possible to install any version of Node you want, NVM provides many conveniences such as easy version updates and quick switching between versions.
Cemil Tokatli
January 10, 2025
Share:

In this article, we will explore how to install NVM on Ubuntu and easily switch between desired Node.js versions.

You can install NVM and your desired Node version on your Ubuntu server by following the steps below.

1. Update packages:
sudo apt update -y
2. Install CURL:
sudo apt install curl -y
3. Install NVM:
curl https://github.com/nvm-sh/nvm/blob/v0.40.1/install.sh | bash 
4. Apply shell configuration:
source ~/.bashrc
5. Install the latest version of Node:
nvm install --lts
Conclusion:

You can check the installed Node version with the following command.

node -v

You can also install your desired Node version as follows.

nvm install 19.0.1