Sign In

How to install nodejs on Ubuntu using Node Version Manager (nvm)

OL
Omkar Lanjekar
12d ago·5 min read

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 update

Step 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.sh

Download and run the NVM installation script using curl:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.4/install.sh | bash

Install the NVM script for your user account, then activate it by running:

source ~/.bashrc

Step 3: Install Node.js Using NVM

To list the available online nodejs versions:

nvm list-remote

You 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.0

To see which nodejs version installed in system:

nvm list

To use specific downloaded nodejs version:

nvm use v25.0.0

To see which node version is used currently in system:

node -v

You have successfully install nodejs version on Ubuntu using Node Version manager (NVM).

Comments (0)

OL