How to install nodejs on Ubuntu using Node Version Manager (nvm)
Node.js is a popular JavaScript runtime that allows developers to run JavaScript on the server side. Managing Node.js versions can sometimes be tricky, but Node Version Manager (NVM) makes it easy. With NVM, you can install multiple versions of Node.js and switch between them effortlessly.
Step 1: Update Your System
Before installing anything, it’s a good practice to update your system packages:
sudo apt updateStep 2: Install NVM
To install NVM on your Ubuntu machine, visit the project’s GitHub page. Copy the curl command from the README file that displays on the main page. This will get you the most recent version of the installation script.
Before running a downloaded script, don’t pipe it directly to bash. First, download it with curl (without | bash) and inspect the file to ensure it’s safe. Once verified, you can execute it.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.4/install.shDownload and run the NVM installation script using curl:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.4/install.sh | bashInstall the NVM script for your user account, then activate it by running:
source ~/.bashrcStep 3: Install Node.js Using NVM
To list the available online nodejs versions:
nvm list-remoteYou can install any listed Node version listed by specifying it during installation. For example: to install v24.13.0 you can run below command:
nvm install v24.13.0To see which nodejs version installed in system:
nvm listTo use specific downloaded nodejs version:
nvm use v25.0.0To see which node version is used currently in system:
node -vYou have successfully install nodejs version on Ubuntu using Node Version manager (NVM).