Nowadays Node.js is gaining popularity due to the various advantages and even Node.js has taken over web development in small as well as in large enterprises. Firstly we will understand what is Node.js and its advantages before moving forward to learn the different ways to update Node.

What is Node JS?

It is a cross-platform JavaScript environment that allows server-side scripting and it also ensures a non-blocking workflow thus making it popular amongst developers to create web-based applications. This also provides a node package manager that is also known as npm.

Some advantages of Node are mentioned below:

  • Due to the Node, you can create real time applications with great efficiency.
  • You can use the Node.js to build the JavaScript code for both the client and server side.
  • It also enhances the development process efficiency as it bridges the gap between the frontend and backend developers.

There are 3 ways to update Node.js to the latest version on Linux systems which are given below:

Option 1: Update Node.js with NVM (Node Version Manager)

It is the best way to update the node.js is with NVM as it is a practical tool for managing multiple node.js versions.

Firstly you need to start by updating the package repository with the command:

sudo apt update

After that you have to install the NVM by using the curl command:

curl -o- | bash

By using the alternative way, you have to use wget and then run the command:

wget -q0- | bash

After that you have to close and reopen the terminal for the system to recognize the changes or run the command:

source ~/.bashrc

After that you need to verify if you have successfully installed NVM:

nvm --version

You need to check the version which you are running on the system before upgrading the node.js:

nvm ls

After that you can check for the newly available releases with:

nvm ls-remote
  • If you want to install the latest version, you have to use the NVM command with the specific node.js version:

Option 2: Update Node.js with NPM (Node Package Manager)

You can update the node.js  using the NPM and it is a tool for installing and managing the package dependencies. To complete this option, you need to do some steps which are given below:

Firstly you need to clear the NPM cache:

npm cache clean -f

After that you need to install n, Node’s version manager:

nop install -g n
  • Within the n module installed, you can use it to:

Install the latest stable version:

sudo n stable

Then you have to download some specific versions:

sudo n latest
sudo n [version.number]

Option3: Update the node.js with the binary packages:

If you want to update the Node.js with the binary packages then it is the least recommended option and it is the only way in which you can upgrade to the latest node.js version and for this, you need to follow the steps which are outlined below:

  • Firstly you have to navigate the Node’s official downloads page from where you can download the source code you can pre-built installer for the LTS versions or the latest release.

After that, you can either download the package from the browser or you can find the version number which you need and then add it to the wget command:

  • In this step you have to install xz-utils which is used to extract the binary package:
sudo apt-get install xz-utils

In last you need to extract and then install the package with the command:

tar -C /usr/local --strip-components 1 -xJF node-v14.17.0-linux-x64.tar.xz

Update Node Js latest version on windows and macOS

There are two ways to upgrade node.js to the latest version which are given below:

  • For that you have to first download the latest Node.js release from its official download page and then install the new node.js release.
  • After that you need to install the n module and update the node.js inside the terminal window.

Option1: Update Node.js on Windows and macOS with the installer:

This is the first way to update your node.js is to go to its official download page and then install the newest release.

  • Firstly you have to navigate to the node.js website and then click on the latest stable version or the newest current release.
  • Then after the decision of version you need to click on the windows or the macOS  installer, which will depend on the system you are using.
  • Once the download gets complete, run the installer.
  • After running the installer, the Node.js setup wizard will appears and guides you through the installation.
  • After that you have to accept the license agreement by checking the box and then click on next.
  • Then you have to choose the destination folder from where you want to install the node.js.
  • In this step, it will allows you to select that how you want to install the node features and after that change the way of the features.
  • And with that, the latest Node.js will be ready to install and then click on install to confirm and wait until the installation completes and then click on finish.
  • At last check the Node.js version with the command:
node -v
How can I update npm on Windows? - Stack Overflow

Option2: Update Node.js on Windows and macOS with NPM:

If you want to update the Node.js from the command line then use the n model within the NPM command and this n feature will allow you to interact with the different Node.js versions.

How to Update Node.js to Latest Version {Linux, Windows, and MacOS}
  1. Firstly check the version which you are using before updating the node.js:
node -v

2. Then clear the NPM cache with the command:

npm cache clean -f

After that install the n globally:

npm install -g n

Now you can use the module to install the latest stable release of Node.js as you have now n installed:

sudo n stable

Then you can install the node.js alternatively which will release with the latest features:

sudo n latest

  Or even you can install a specific version number with:

n [version.number]


From the above article, we have concluded that the best part of open-source technology is the strong community of users who are constantly working on upgrading the software.

The node js is the best example of some software as the new versions come out regularly and even the users can choose whether they want to work with the LTS(long term supported version) or you want to work with the latest version with the newest features.

Categorized in: