How to update NodeJS and NPM to their latest versions?

Node.js and NPM (Node Package Manager) both are popular and widely used tools among the developer’s community. On one side where nodejs is a JavaScript run-time environment, NPM is its package manager to install various libraries and packages for it, easily. Both tools are used worldwide to build and run modern web applications. Therefore, keeping them up to date with their latest versions is essential to ensure that your projects are secure, efficient, and compatible with the latest features.

And in this tutorial, we are going to learn how to make sure your Node.js and NPM are up to date with their latest versions on different operating systems.

Updating Node.js and NPM on Windows:

Step 1: On your Windows 10 or 11, first open the command terminal. For that, you can search for CMD and open it as Admin or by pressing Win key + R and typing cmd in the run box, after that press the shift+Alt key and hit the Enter key.

Step 2: Now, let’s check which version of Node.js is currently installed by typing the following command in the prompt:

node -v

Step 3: If your current version of Node.js is outdated then you have to download the latest version either by visiting the official website of Node.js or with the help of the given command line.

For Node.JS long-term release version.

winget install OpenJS.NodeJS.LTS

For Current release:

winget install OpenJS.NodeJS

For Nightly build or still in the testing stage:

winget install OpenJS.NodeJS.Nightly

Step 4: Once the installation is complete, again check the version of Node.js to confirm the updated version by typing the command:

node -v

Step 5: Although updating Node.js will also install the updated version of NPM, however, if you want to update it individually then here is the command to use:

npm install -g npm@latest

Update Node.js and NPM on macOS:

Step 1: It is better to first know which version of Node.js is running on our macOS. So, open your command terminal, you can do that by searching for it in Spotlight or by going to Applications -> Utilities -> Terminal.

Step 2: Run the given command to check the currently installed version of it.

node -v

Step 3: Once you are assured that the installed version of Node.js is not the latest one, visit the official website of Node.js and click on the MacOS option to download the latest available Node.js version.

Step 4: As you have downloaded the latest package of this JavaScript environment, run it and start following the installation process. As it is completed, again in your command terminal check for the Node version but this time you will have the latest one.

Step 5: Whereas, those who just want to update NPM to the latest version, can use this this command in terminal.

npm install -g npm@latest

Updating Node.js and NPM version on Linux:

Note: The following steps are written to get the latest current or LTS version of Node.js, if your project is relying on some older version then act accordingly.

Step 1: According to your Linux system, open the terminal app from your application menu. Ubuntu users can use the keyboard shortcut – Ctlr+Alt+T.

Step 2: Before getting the latest version, let’s check what is the currently installed one. For that in your command terminal run:

node -v

Step 3: If there is some difference between the version listed on the Node.js website and the one on your system then it means it is outdated, we need to download the latest one.

For that add the Nodejs repository as per your Linux system.

If you are on Ubuntu, Linux Mint, Debian, POP OS, MX Linux and other DEB based systems:

Note: Only Use one repository, not both.

For the latest current version:

curl -fsSL | sudo -E bash -

For LTS- Long Tem Supported version use this repo instead above one:

curl -fsSL | sudo -E bash -

For RPM-based Linux such as RHEL, Fedora, Alma Linux, Rocky, Oracle, etc.

To install and update the current Nodejs version:

curl -fsSL | bash -

To install and update Nodejs LTS version:

curl -fsSL | sudo -E bash -

Step 4: Now, run the installation or update command.

For Debian or Ubuntu based OS.

sudo apt install -y nodejs
sudo apt update && sudo apt upgrade

For RPM Based linux:

sudo dnf install -y nodejs
sudo dnf update

Step 5: Once the installation is completed, check the version of Node.js by typing the command:

node -v

Step 6: To update NPM to the latest version on Linux, just like Windows or macOS use the following command:

sudo npm install -g npm@latest


So, in this tutorial, we have learned the simple methods to get the latest version of both Nodejs and NPM packages. But before upgrading it is a good idea to check whether your existing project is compatible with the update or not.

Other Articles:

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.