How to Update NodeJS to Latest Version on Ubuntu 24.04

You should consider updating NodeJS to the latest version in Ubuntu 24.04 as it improves performance, enhances security, and brings new features.

Let’s get you through the methods to update NodeJS on Ubuntu 24.04.

1. Update NodeJS to the Latest Version on Ubuntu 24.04 Using NVM

NodeJS is officially available on Ubuntu 24.04. However, before updating it, install NodeJS following our detailed guide to install NodeJS on Ubuntu 24.04.

Let’s explore the steps to update NodeJS to the latest version on Ubuntu 24.04 using NVM:

Step 1: Update System Packages

First update system’s packages:

sudo apt update

Step 2: Download and Install NVM

Next, download and install NVM using:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v.39.7/install.sh | bash
downloading and installing nvm using the curl command on ubuntu 24.04

Step 3: Refresh the “bashrc” File

To trigger the changes from step 2, refresh the “bashrc” file using:

source ~/.bashrc
refreshing the bashrc file on ubuntu 24.04

Step 4: Check Current NodeJS Version

Before updating NodeJS, check its current version on Ubuntu 24.04 via:

nvm ls

Step 5: Update to the Latest NodeJS Version

Run the below command to automatically install the latest (updated) NodeJS version on Ubuntu 24.04:

nvm install node
installing the latest version of nodejs using nvm on ubuntu 24.04

Note: If you are annoyed by Ubuntu 24.04’s automatic updates, follow our guide to Disable Automatic Updates on Ubuntu 24.04.

2. Update NodeJS to the Latest Version on Ubuntu 24.04 Using APT

To update NodeJS to the latest version on Ubuntu 24.04 using APT, follow these steps:

Step 1: Update System Repositories

First update the system’s repositories using:

sudo apt update

Step 2: Install NodeJS to the Latest Version

Now, update NodeJS to the latest version on Ubuntu 24.04 with:

sudo apt upgrade nodejs -y
upgrading nodejs to the latest version using apt on ubuntu 24.04

Note: If you see the error “unable to locate nodejs“, install NodeJS using “sudo apt install nodejs -y“.

In older versions of Ubuntu, you can use npm to install the desired NodeJS version, however, it no longer works in Ubuntu 24.04.

Conclusion

To update NodeJS to the latest version on Ubuntu 24.04, run “sudo apt upgrade nodejs -y“. Additionally, you can install “nvm“, check for available versions, and install the latest version.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top