Upgrading Node.js is not just a routine maintenance task but a critical step in keeping your applications efficient, secure, and aligned with modern development standards. As one of the most widely adopted JavaScript runtime environments, Node.js is the building block of millions of web applications and is frequently updated with performance improvements, security patches, and new capabilities. You cannot ignore these updates, as they can have serious repercussions for a Node.js development company. In this guide, we’ll walk you through the complete process of how to upgrade Node.js across Windows, Linux, and macOS, ensuring you can adopt the newest version without disrupting your current workflow. It will help you make a correct decision for your application’s long-term stability and scalability.
1. Why Should You Upgrade Node.js Version?
The following are some of the most compelling reasons behind the necessity of Node.js upgradation:
1.1 Stronger Protection Against Threats
Upgrading Node.js ensures your application benefits from the latest released security patches that address known vulnerabilities. Older versions often contain vulnerabilities that attackers can exploit. By staying updated, your system gains stronger defence layers, reducing risk and keeping sensitive information safe across every interaction and process.
1.2 Noticeable Performance Improvements
Each new Node.js release comes with refined internal processes, faster execution times, and efficient resource handling. These enhancements result in quicker response speeds and smoother operations for your applications. Updating helps your system scale more efficiently and deliver consistently faster performance, no matter how much your user base or operational load continues to grow.
1.3 Better Stability for Long-Term Projects
Modern Node.js versions are built with upgraded modules, fixed bugs, and smoother runtime behaviour. As a result, the chances of sudden crashes decrease, and you can achieve a predictable performance. Updating ensures your application runs on a reliable and well-tested foundation, which becomes crucial for systems handling complex tasks or long-running background operations.
1.4 Access to New Functionalities
Every upgrade comes with its own set of language features, improved APIs, and refined development tools. These additions help developers write cleaner and more maintainable code with greater flexibility. By keeping Node.js updated, teams can adopt modern JavaScript capabilities and take advantage of powerful new functionalities designed to streamline workflow and enhance development speed.
1.5 Improved Compatibility With Libraries and Tools
The Node.js ecosystem evolves quickly, and hence, many third-party libraries stop supporting older versions. Updating ensures you can use the latest frameworks, packages, and integrations without facing compatibility issues. This reduces development friction, prevents dependency conflicts, and keeps your project aligned with current industry standards and best practices.
1.6 Reduced Maintenance Costs and Technical Debt
Running outdated Node.js versions often leads to recurring bugs, dependency issues, and increased troubleshooting. You can avoid these issues and work on an efficient runtime environment by upgrading your Node.js application at regular intervals. Staying updated lowers long-term maintenance effort, reduces development bottlenecks, and helps teams manage their codebase with greater clarity and control.
2. How to Upgrade Node.js?
There are different methods to update Node.js for different operating systems. The method depends on which OS you’re working on and which method is most suitable for it. In the upcoming sections, we’ll explore in detail all the important methods for upgrading Node.js for Windows, macOS, and Linux.
2.1 How to Update NodeJS Version on macOS?
There are primarily four ways to accomplish the updation of Node.js on macOS:
Method 1: Upgrade Node.js with macOS Installer
You have the option to take complete responsibility for Node.js updates into your hands with this method. You can do so by manually updating your Node.js version with the help of the .pkg installer by downloading it from the official website using the steps given below:
1. Download the macOS installer
Go to the official website of Node.js and download the latest version’s .pkg (macOS) installer for your Mac. There are two options here:
- If the priority is for the latest stable version, go for downloading the LTS (long-term support) version.
- If you desire the latest and advanced features for superior performance, go for downloading the current version.
You need to take care that the downloaded file is saved in the desired folder to avoid any inconvenience.
2. Run the downloaded macOS installer
Navigate to the folder where the file is saved. Double-click on the file to start the installation wizard, and then proceed as per the given on-screen instructions. Confirm the license agreement, choose the destination directory, and the features you want to install. The following is a crisp summary of actions to be taken:
Introduction > Continue License > Select Continue > Agree Installation Type > Install > Authenticate with your Mac to allow the Installation > Install Software Summary > Close |
3. Verification of the installation
Installing the updated version, do not mark the end of the process. Once the installation process is over, you even need to validate that the installation has been done properly on your macOS. For this, run the following command on your terminal:
node -v |
4. Updation of NPM
It’s possible that the Node.js upgrade may not update the existing NPM version. To update the NPM version, execute the following command:
npm install -g npm@latest |
5. Verification of the NPM installation
Execute the following command to verify that the latest version of NPM is installed on your system:
node -v |
Method 2: Update Node.js on macOS with Homebrew
Homebrew is a free and open source package manager that simplifies the installation of software and its dependencies using just a single command. If you’ve used or are planning to use Homebrew for installing Node.js, this method is for you to ensure a smooth upgrade. It is one of the simplest approaches to upgrading Node.js.
1. Homebrew installation
Go to the official website at brew.sh and install the package according to the installation instructions.
2. Brew updation
Before installing the updated Node.js version, ensure that your package is the latest version containing all updated definitions. Verify it using:
brew update |
3. Node.js installation
Open the terminal and type the command below to install Node.js if it isn’t:
brew install node |
4. Node.js updation
If your Mac already contains Node.js, use the commands below to upgrade it to the latest version:
brew upgrade node |
5. Verification of Node.js Updation
As we did for installation using the macOS installer, here also we’ll verify the correct installation of Node.js with the following command:
node -v |
6. NPM Updation
If you want, you can even update the NPM using:
npm install -g npm |
Method 3: Updating Node.js Using NVM (Node Version Manager)
It has been observed many times that the latest version is not necessary for certain projects. You might need to work on older or specific Node.js environments. For such cases, NVM is the best choice. Node Version Manager, or NVM, not only allows you to install the latest Node.js version, but also switch between and manage different Node.js versions on a single system.
1. Check NVM installation
First of all, check whether NVM is installed on your system. If yes, which version is it? For that, type the following command in the terminal:
node -v |
If your system doesn’t have NVM, you have two ways to install it:
1.1. With cURL
curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash source ~/.bashrc # or ~/.zshrc |
1.2. With wget
wget -q0- https://raw.githubusercontent.com/creationix/nvm/v0.40.2/install.sh bash // |
After the download and installation process is complete, reload the shell for the changes to take effect:
source ~/.zshrc # For Zsh users source ~/.bashrc # For Bash users |
2. NVM installation verification
Check if the latest version of NVM installation has been appropriately done with the following command:
node -v |
3. Checking Node.js version
Type the command below in the terminal to get the list of current versions of Node.js installed on your system:
nvm ls |
4. Node.js installation
Once you’re aware of the versions present in your system, it’s easy to determine the required Node.js version. The command below will install the latest stable version of Node.js:
nvm install node-lts |
5. Switching versions
As there can be multiple Node.js versions in your system, you’ll have to switch to the latest installed version using the given syntax:
nvm use node |
If you want to switch to some other versions, you can use the following command:
nvm use [version] |
The [version] here will include the version number you want to switch to.
6. Setting default version
If you think that there’s no requirement to work on previous Node.js versions for quite a long time, you can make this latest version your default Node.js environment using:
nvm alias default node |
7. Verification of Node.js Updation
At the end, run the below command to ensure the updation of Node.js:
node -v |
Method 4: Updating Node.js on macOS Using NPM
The Node Package Manager offers a lighter and simpler approach to upgrading Node.js, as you’ll not have to deal with too much code and avoid complexity. Its n module facilitates easy installation and management of Node.js versions. So let’s move towards the installation process:
1. Checking Node.js version
Take a look at the version number of the Node.js present in your system with the help of the command below:
node -v |
2. Free the NPM cache
Before reinstalling your project libraries, it’s a good idea to remove any stored modules that NPM keeps for faster installs. This cache can sometimes hold outdated or corrupted files, which may interfere with fresh dependency downloads. Clearing it ensures that every package is pulled directly from the source instead of reusing previously saved data.
Use the command below to free up the cache:
npm cache clean -f |
3. n module installation
If the n module is not installed, install it globally using npm. By setting it up this way, you allow the package to function consistently across all environments and projects without requiring separate installations.
npm install -g n |
4. Node.js installation
Once the tool is set up, you can decide which Node version to install by selecting from several options:
- For installing the latest stable version
sudo n stable
- To install the recent Node.js release for accessing the updated features:
sudo n latest
- For installing the latest long-term support (LTS) release:
sudo n lts
5. Removal of previous versions
Running the below command clears out older Node versions that were stored from past installations, leaving only the most recent one in place.
n prune |
2.2 How to Upgrade Node.js Version on Windows?
There are primarily four ways to accomplish the updation of Node.js on Windows:
Method 1: Update Node.js with Windows Installer
This is the easiest way to upgrade Node.js on your Windows system. In this method, the updated version replaces or overwrites the existing version present in your system. You just need to download and run the installer as you do for installing other software.
1. Download the Node.js installer
Go to the official website of Node.js and download the latest version’s Windows Installer (.msi) for your Windows. There are two options here:
- If the priority is for the latest stable version, go for downloading the LTS (long-term support) version.
- If you desire the latest and advanced features for superior performance, go for downloading the Current version.
Here you can either use a package installer or download the source code, depending on your needs. You need to take care that the .msi file is saved in the desired folder to avoid inconvenience.
2. Run the downloaded MSI installer
Navigate to the folder where the .msi file is saved. Double-click on the file to start the installation wizard.
3. Follow the installation instructions:
The setup wizard opens, on which you need to follow the sequence given below:
- Welcome Screen: Press the “Next” button to proceed.
- License Agreement: Read and confirm the license agreement, then click “Next.”
- Destination Folder: Select the folder you want for Node.js installation, then click “Next.”
- Tools for Native Modules: Click the options to install/update tools for native modules like Python, Visual Studio Build Tools, and Chocolatey, then click “Next.”
- Install: Click “Install” to begin the installation process after you’ve decided on the features you want to install/update.
- Finish: Wait for some time to finish the installation process before clicking the “Finish” button to exit the installer.
4. Verification of the installation
When installing the updated version, do not mark the end of the process. Once the installation process is over, you even need to validate that the installation has been done properly. For this, run the following command on your terminal to check the installed Node.js version:
node -v |
5. Updation of NPM
It’s possible that the Node.js upgrade may not update the existing NPM version. To update the NPM version, execute the following command:
npm install -g npm@latest |
6. Verification of the NPM installation
Execute the following command to verify that the latest version of NPM is installed on your system:
node -v |
Method 2: Update Node.js using nvm
We know that Node Version Manager, or NVM, allows us to work on multiple versions of Node.js on the same machine by switching to the required version whenever needed. Go through the following step-by-step guide:
1. NVM installation
- Go to the nvm-windows GitHub releases page and download the nvm-setup.zip installer from its Assets section.
- Locate the downloaded nvm-setup.zip file. Right-click on it and select “Extract All.” Choose a destination folder for the extracted files.
- Navigate to the extracted folder and double-click the nvm-setup.exe file to initiate the installation wizard.
- Accept the license agreement by selecting “I accept the agreement” and clicking “Next.”
- Accept the default installation locations for both NVM and the Node.js versions directory by clicking “Next” on the respective screens.
- Click “Install” to begin the installation process.
- The installation wizard prompts whether NVM should manage any existing Node.js installations on your system. Selecting “Yes” allows NVM to take control of these installations, enabling the user to switch between different Node.js versions, including those already present, using NVM commands.
- Once the installation is complete, click “Finish” to exit the wizard.
2. NVM installation verification
Check if the latest version of nvm-windows installation has been appropriately done by entering the following command in the command prompt :
node -v |
3. Checking available Node.js versions
Type the command below in the terminal to get a reference to the available latest versions of Node.js:
nvm list available |
4. Node.js installation
Now that you know the available versions, select the one you want to install and install it using the syntax below
nvm install <version> |
- For the latest version installation:
nvm install latest
- For installing the latest LTS version
nvm install lts
5. Activating the installed version
Use the following command to switch to the latest installed Node.js version:
nvm use <version> |
The <version> here will include the version number you want to switch to.
6. Verification of Node.js Updation
At the end, run the below command to ensure the updation of Node.js and NPM:
node -v |
7. Setting default version
If you need to work on a particular Node.js version for quite a long time, you can set that version as your default working version with the help of:
nvm alias default version |
Method 3: Update Node.js Using NPM
The Node Package Manager offers a lighter and simpler approach to upgrading Node.js, as you’ll not have to deal with too much code and avoid complexity. Its n module facilitates easy installation and management of Node.js versions. So let’s move towards the installation process:
1. Checking Node.js version
Take a look at the version number of the Node.js present in your system with the help of the command below:
node -v |
2. Free the NPM cache
Before reinstalling your project libraries, it’s a good idea to remove any stored modules that NPM keeps for faster installs. This cache can sometimes hold outdated or corrupted files, which may interfere with fresh dependency downloads. Clearing it ensures that every package is pulled directly from the source instead of reusing previously saved data.
Use the command below to free up the cache:
npm cache clean -f |
3. n module installation
If the n module is not installed, install it globally using npm. By setting it up this way, you allow the package to function consistently across all environments and projects without requiring separate installations.
npm install -g n |
4. Node.js installation
Once the tool is set up, you can decide which Node version to install by selecting from several options:
- For installing the latest stable version
sudo n stable
- For installing the recent Node.js release for accessing the updated features:
sudo n latest
- For installing the latest long-term support (LTS) release:
sudo n lts
Method 4: Updating Node.js via Chocolatey
Chocolatey serves as a command-line tool that brings streamlined software installation and updates to Windows, offering a workflow similar to package managers found in Linux distributions. With it, applications can be added, upgraded, or removed through simple commands, eliminating the need to manually download installers.
Below are the steps to be taken when upgrading Node.js using the Chocolatey package manager:
1. Chocolatey Installation
Open “Windows PowerShell” in admin mode to obtain the required permissions to install Chocolatey if it’s not already there. Run the following command to install Chocolatey:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) |
2. Upgrading Chocolatey
Make sure that the installed Chocolatey is its latest version. Type the following command to upgrade Chocolatey and then press Enter:
choco upgrade chocolatey |
If any prompt appears asking if you want to continue the Chocolatey update, press y and then Enter.
3. Node.js installation
Search for all the available Node.js versions to install the one you require:
choco find nodejs.install |
After entering this command, you’ll see a list of available Node.js versions.
4. Node.js updation
Get the latest Node.js version on your system with the help of:
choco upgrade nodejs.install |
To run the Node.js upgrade, execute the installation script. When prompted, confirm the installation by entering y and pressing Enter. This action will update Node.js to its latest available version.
2.3 How to Update NodeJS Version on Linux
There are primarily three ways to accomplish the updation of Node.js on Linux:
Method 1: Updating NodeJS version on Linux Using NVM
Upgrading Node.js on a Linux system is easiest using NVM, or Node Version Manager. NVM provides the best practical approach to working with multiple versions of Node.js on your Linux system.
Go through the steps below to upgrade your Node.js using NVM on Linux systems:
1. Package Repository Updation
The first thing you need to do is update the repository for system packages using the syntax below:
sudo apt update |
2. Download dependencies
To run nvm properly, you need to download some important dependencies before installing nvm using the following command:
sudo apt install build-essential checkinstall libssl-dev |
3. NVM installation
You can install or update NVM in the following two ways:
- Using the curl commandIf your Linux distribution does not contain curl by default, then use the syntax below to install it
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
sudo apt install curl
- Using wget
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
Running these commands downloads the required script for installing or updating NVM on your Linux system.
4. Restarting terminal
You will have to close and restart the terminal to make the changes visible. You can even execute the command below to recognise the changes:
source ~/.bashrc |
5. NVM installation verification
Check the version number of the installed NVM to verify its successful installation:
nvm --version |
6. Checking Node.js version
First of all, you need to be aware of the Node.js version already present in your system, and for that, use:
nvm ls |
7. Check NVM releases
nvm ls-remote |
You’ll get a list of all the available Node.js releases. Move to the bottommost part to find the current release.
8. Node.js installation
You’ve already found the latest Node.js release from the above list, so it’s time to install it using the nvm command, having mentioned the Node.js version number:
nvm install [version_number] |
Method 2: Updating NodeJS Using Node Package Manager (NPM)
The Node Package Manager, or NPM, is the default package manager of Node.js. So, if you’ve installed Node.js in your system, NPM is also present in it by default. You can make use of NPM’s n module, i.e. Node Version Manager, to upgrade Node.js in the following sequential manner:
1. Free the NPM cache
Clearing the cache is a good practice to avoid interference of the stored modules with the new downloads.
npm cache clean -f |
2. N module installation
If the n module is not installed, install it globally using npm.
npm install -g n |
3. Node.js installation
Now that you have the n module installed, you can decide which Node version to install by selecting from several options:
- For installing any specific Node.js version:
sudo n [version_number]
- For installing the latest stable version:
sudo n stable
- For installing the recent Node.js release for accessing the updated features:
sudo n latest
- For installing the latest long-term support (LTS) release:
sudo n lts
The n package installs Node.js into a new directory and modifies your system’s PATH variable to utilise the newly installed version. For these changes to come into effect, a restart of your terminal or a full logout and log back in may be necessary.
Note: If running the n command in some Ubuntu distributions results in a “command not found” error, this denotes that the n package is not installed or not accessible in your system’s PATH. Use the following command to overcome this limitation:
sudo -E env "PATH=$PATH" [command] |
Method 3: Updating NodeJS Using Binary Packages
This is the last and least advisable method to upgrade Node.js on your Linux system due to potential security risks and management complexity, especially related to dependency resolution. However, in environments where package managers are unavailable or unsuitable, this method can be employed.
The following instructions will help you upgrade Node.js using this method:
1. Visit the Node.js website
Go to the Node.js official download page to take a look at the list of all the available packages. You’ll see the Linux binary files in the list.
2. Binary Package download
Choose the file you want to download for your Linux system according to the latest version, OS, and system architecture. You can download the source code directly or go for the pre-packaged installer. You can even copy the download link and add it to the wget command like this:
wget https://nodejs.org/dist/v22.6.0/node-v22.6.0-linux-x64.tar.xz |
3. Binary Package extraction
Extract the binary package by installing the xz-utils package using the following command:
sudo apt-get install xz-utils |
4. Binary Package Installation
Make use of the command below for installing the downloaded package:
sudo tar -C /usr/local --strip-components 1 -xJf [package_name] |
For instance,
sudo tar -C /usr/local --strip-components 1 -xJf node-v22.6.0-linux-x64.tar.xz |
5. Checking Node.js version
Confirm the version of Node.js to ensure its successful installation using:
/usr/local/bin/node -v |
3. Final Thoughts
Node.js is a powerful runtime environment. Updating to its latest versions significantly enhances the overall application, unlocking a range of advantages. These benefits range from the integration of modern features to the assurance of Long Term Support (LTS), solidifying Node.js’s position as a preferred choice among developers. Maintaining an updated Node.js installation proves advantageous, delivering optimal performance, enhanced reliability, robust security, and a plethora of advanced functionalities.

Comments
Leave a message...