Categories: TutorialsUbuntu

How to update Node JS on Ubuntu 18.04

In this short tutorial, you will discover three ways to update NodeJs on Ubuntu 18.04 and 20.04.

Using nvm

Let’s start with NVM, Node Version Manager.

It is by far the best method to update NodeJS on Linux machines.

You will need a C ++ compiler, the package build-essential and the library libssl-dev. Run an update first, then we’ll install the packages.

sudo apt-get update

To install the packages, run the command :

sudo apt-get install build-essential checkinstall libssl-dev

Sponsored

How to install NVM: To install or update NVM, you can get the installation script using cURL:

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

To check if the installation was successful, invoke the command :

nvm -v

The command will return the version of nvm if all goes well. Your Node JS update will become easy.

Read: How to install Node.js on Linux/Ubuntu

You can check which versions are currently installed with the command :

nvm ls

To see the latest npm version for installation, run the command :

nvm ls-remote

Download, install and compile the latest versions of Node JS using

nvm install #. #. #                        [update nodejs ubuntu]

Replace the #s with the required Node JS version.

Using a package manager

If NVM didn’t work for you, a package manager is now your best alternative.

The Node Package Manager, or NPM, helps you discover, share, and use code, along with dependencies. Node JS comes with npm pre-installed, but it is updated more often than Node.

Run the command:

npm -v

To see what your current version is.

Now to install the latest version of npm, execute the command :

Sponsored

npm install npm@latest -g [install npm ubuntu]

Next invoke :

npm -v

Again to make sure that the update has been done correctly.

Now to update Node JS, you will need an npm module called “n”.

Run the lines of code below on your terminal to clear the npm cache, install the “n” module and install the latest stable version of Node JS.

sudo npm cache clean -f

sudo npm install -g n

sudo n stable

To install the latest version, run the command :

sudo n latest

Or otherwise, you could also execute:

sudo n #. #. #

As it was the case with the first method, replace the #s with the required Node JS version.

Using binary packages

If you are desperate and the other options didn’t work out, you can visit the official downloads page to get a 32-bit or 64-bit binary package.

You can install the package via the browser itself, but if you prefer to use the terminal, keep in mind that the specific version of the node may change while updates are released.

On your terminal, run the command:

wget https://nodejs.org/dist/v14.15.3/node-v14.15.3-linux-x64.tar.xz

To unzip the file, you will need the xz-utils package, to install it, run :

sudo apt-get install xz-utils

Now run the command below to extract and install the binary package in /usr/local:

tar -C /usr/local –strip-components 1 -xJf node-v14.15.3-linux-x64.tar.xz

The post How to update Node JS on Ubuntu 18.04 appeared first on net2.

Ubuntu Server Admin

Recent Posts

Cut data center energy costs with bare metal automation

Data centers are popping up everywhere. With the rapid growth of AI, cloud services, streaming…

20 hours ago

Build the future of *craft: announcing Starcraft Bounties!

Our commitment to building a thriving open source community is stronger than ever. We believe…

20 hours ago

NodeJS 18 LTS EOL extended from April 2025 to May 2032 on Ubuntu

The clock was ticking: Node.js 18’s upstream End of Life (EOL) The OpenJS Foundation is…

20 hours ago

Native integration now available for Pure Storage and Canonical LXD

June 25th, 2025 – Canonical, the company behind Ubuntu, and Pure Storage, the IT pioneer…

2 days ago

Revolutionizing Web Page Creation: How Structured Content is Slashing Design and Development Time

Co-authored with Julie Muzina A year ago, during our Madrid Engineering Sprint, we challenged ourselves…

3 days ago

Ubuntu Weekly Newsletter Issue 897

Welcome to the Ubuntu Weekly Newsletter, Issue 897 for the week of June 15 –…

4 days ago