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