How to Update Node.js to the Latest Version (Feb. 2024)

Update Node Js Latest Version

Learning how to update Node.js to the latest version on a web server only takes a few lines of command line code.

As an open-source project, Node.js moves fast in development. Minor updates come out every few weeks to boost stability and security, so you’ll want to keep up to protect your applications.

Several methods abound for updating Node.js on different operating systems. We’ve compiled some of the simplest and most effective ways to install the newest version of Node.js on Linux, Windows, and macOS machine, and highlighted some of the best web hosts best for Node.js.

How to Update Node.js on Linux (Ubuntu, Debian, and CentOS)

The exact steps to updating Node.js on a Linux system can vary by distribution, but our recommended methods will work across most versions. We value simplicity and effectiveness in systems administration and, for us, the easiest method is to use Node Version Manager (nvm).

Before you start, check which version of Node.js you’re currently using by running node -v in a command line terminal.

If extenuating circumstances prevent you from using nvm, you can rely on the resources of Node Package Manager (npm). This guide also includes instructions for updating Node.js through binary packages with version-specific references.

1. Update Node.js Using Node Version Manager (nvm)

Node Version Manager, or nvm, is far and away the best method for updating Node.js. You’ll need a C++ compiler, as well as the build-essential, and the libssl-dev packages.

Run an update of nvm first, then get the latest packages of Node.js to update your web server environment:

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

To update to the latest version of nvm, you can get the install script by using cURL:

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

You’ll have to close and re-open the terminal first, but you can verify a successful installation by using command -v nvm. The command will output the current nvm version if everything worked.

Once you’re set up with the latest version of nvm, installing updated distributions of Node.js is a breeze.

You can check what versions are currently installed on your server with nvm ls and see what is available to install from the public repository by using the nvm ls-remote command.

Download, compile, and install a new version of Node.js with nvm install #.#.#, obviously substituting the #s for the Node.js version you want.

You can tell nvm which version to use in each new shell with nvm use #.#.# and set a default with alias: nvm alias default node.

2. Update Node.js Using a Node Package Manager (npm)

If nvm isn’t for you, a package manager is your next best bet. Node Package Manager, or npm, helps you discover, share, and use code, along with managing dependencies in software development. Node Package Manager contains more than 800,000 code packages for developers.

Node.js comes with npm pre-installed, but the manager framework is generally updated more frequently than Node.js. To use this method for updates, follow the steps below:

  • Run npm -v to see which installed version you’re currently using.
  • Run npm install npm@latest -g to install the most recent npm update.
  • Run npm -v again to validate that the npm version was updated correctly.

To update Node.js, you’ll need npm’s handy n module. Run the code below to clear npm’s cache, install n, and update to the latest stable version of Node.js:

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

To install the latest release, use n latest. Alternatively, you can run n #.#.# to get a specific Node.js version if you need to install it because of software compatibility or sandbox testing.

3. Update Node.js Using Binary Packages

Updating Node.js on a web server using binary packages can be a bit more complicated. If you need to use this method, go to the official Node.js downloads page to get the 32-bit or 64-bit Linux binary file.

You can download the file from a browser, but we recommend using the console. Keep in mind that the specific Node.js version might change as updates are released.

wget https://nodejs.org/dist/v6.9.2/node-v6.9.2-linux-x64.tar.xz

To unpack the file, you’ll need xz-utils; to install it, run sudo apt-get install xz-utils. Next, use this code to install the binary package in usr/local:

tar -C /usr/local --strip-components 1 -xJf node-v6.9.2-linux.x64.tar.xz

Now that you have Node.js and npm installed with the binary packages, it should be possible to use the methods outlined in the second option above for the next update of your web server.

Update Node.js to Latest Version on Windows or macOS

As one of the most popular developer frameworks for websites and mobile applications, programming teams should support Node.js across desktop development and web server environments.

Native applications running Node.js on Windows or macOS also need to be updated. Software development teams should integrate DevOps with CI/CD for best results.

Reminder: Before you start, check which version of Node.js you’re currently using by running node -v in a command line terminal.

The guide below covers some of the most common ways to manage Node.js on Windows and macOS operating systems.

Windows desktop developers can use the provided Visual Studio tools to use npm; Homebrew offers similar functionality for macOS users, who can also use nvm.

1. Update Node.js Using the Windows or macOS Installer

The Node.js downloads page includes binary packages for Windows and macOS — but why make your life more difficult?

The pre-made installers — .msi for Windows and .pkg for macOS — make the installation process unbelievably efficient and understandable.

Download and run the file, and let the installation wizard take care of the rest. With each downloaded update, the newer versions of Node and npm will replace the older version.

Developers have their choice of macOS, Windows, or Linux installers on the Node.js download page. You will install the same versions using command line tools with a remote server.

For distributed programming teams, the Node.js Docker image is a great way to collaborate on code. Using the Node.js Docker image enables Agile team collaboration with Git and CI/CD.

2. Windows: Update Node.js With Command Line and PowerShell

Windows users can use the Command Prompt (cmd), PowerShell, or other developer toolsets distributed with IDEs to update Node.js on their local machines for development.

The process is the same for users running Windows Server or IIS for web hosting requirements for ASP.NET.

To open the Command Prompt, just type “cmd” or “command” into the Windows search bar and select the app. For PowerShell, use the same method with the Run as Administrator option.

In the Command Prompt terminal or PowerShell, start with the version check for Node.js:

node -v

This will confirm that Node.js is installed already on your machine and if it needs to be updated to the latest security version. If it is not already installed, you can add npm in PowerShell:

npm install -g npm-windows-upgrade
npm-windows-upgrade

After npm is installed and updated to the latest version, you can use it to manage your Node.js version. If npm is already installed on the machine, you can update it to the most recent release:

npm install -g npm

You now have the option to install Node Version Manager (nvm) on your Windows server or to download and install the latest Node.js binaries with wget. To install nvm, run in PowerShell:

Install-Module -Name power-nvm
Add-Type -AssemblyName System.IO.Compression.FileSystem
nvm install latest
nvm default latest

To install the latest version of Node.js for 32-bit Windows machines:

wget https://nodejs.org/download/release/latest/win-x86/node.exe -OutFile 'C:\Program Files (x86)\nodejs\node.exe'

To install the latest version of Node.js for 64-bit Windows machines:

wget https://nodejs.org/download/release/latest/win-x64/node.exe -OutFile 'C:\Program Files\nodejs\node.exe'

Use the Node.js version check command to confirm you have updated to the latest version:

node -v

Another option for programmers is to use Chocolatey for Node.js installation and package management.

You can also use the resources in Visual Studio Code to manage Node.js and npm versions. This method will allow you to use the Linux subsystem on Windows desktops.

3. macOS: Updating Node.js Version with Homebrew

Homebrew, described as “the missing package manager for macOS,” is the top choice for macOS users to install and manage Node.js.

Install Homebrew by running the following command in the Terminal:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

To install Node.js, open the macOS terminal and enter the command:

brew install node

If you already have Homebrew installed, make sure it is updated to the latest version:

brew update

After this, you only need to run a single command to update the Node.js version:

brew upgrade node

As with Windows installations, you can also download the binary files for Node.js from the website and install them on the desktop manually.

Either method will update Node.js on macOS to the most recent release with other options for configuration of specific versions for testing.

Best Node.js Hosting Providers

Of course, updating Node.js won’t make a huge difference if your website or application lives with a web host that struggles to effectively support Node.js.

Sure, you can find some solid free hosting for Node.js, but the best overall web hosting comes with preinstalled support for the framework and includes automatic updates to the latest version whenever they are released.

This saves developers and programming teams the time of configuration and maintenance of servers.

A2 Hosting has a Node.js module for cPanel that allows you to register an app, install npm, and create a package.json file.

You can also use the command line with the server to configure your apps. The combination of fast NVMe SSD storage on VPS plans makes A2 Hosting a good choice for long-term Node.js support.

At InMotion Hosting, you can install Node.js using EasyApache 4 or over an SSH connection using a command line tool. The company specializes in cheap managed VPS hosting where you can sign up for a plan with 2 vCPU and 2GB of RAM at a very reasonable rate.

InterServer offers a simple button that enables you to create a Node.js application and run npm through a browser-based interface. You can also use an SSH connection to configure apps. InterServer provides cloud VPS plans starting at some of the cheapest rates we’ve found.

A2Hosting.com

A2 Hosting Review

Monthly Starting Price $2.99

  • Turbo server & cache options for faster page loads
  • Well-built plans starting with 4GB RAM
  • FREE CDN plus auto-installs with Softaculous
  • Multilingual support and up to unlimited databases
  • Enhanced security with and daily kernel updates
  • Get started on A2 Hosting now.

VPS
RATING
4.8 ★★★★★ Our Review

A2 Hosting: Our Expert’s Review

Alexandra Anderson (HostingAdvice.com): While A2 Hosting’s turbocharged shared hosting platform gives site owners ample room to grow, the company’s tech prowess is on full display with its portfolio of VPS options. Ranging from unmanaged, bare-metal environments to stress-free, fully managed space, A2 Hosting is sure to have the perfect option for your expanding online presence. Go to full review »

Setup Time Disk Space CPU RAM
7 minutes 20 GB SSD – 450 GB SSD 1 – 10 cores 1 GB – 32 GB

InMotionHosting.com

InMotion Review

Monthly Starting Price $14.99

  • HostingAdvice readers get 67% off the first term
  • FREE site migrations and 2 hours of Launch Assist
  • 2 – 3 dedicated IP address options
  • FREE cPanel/WHM licenses included
  • Highly available servers with real-time redundancy
  • Get started on InMotion now.

VPS
RATING
4.6 ★★★★★ Our Review

InMotion: Our Expert’s Review

PJ Fancher (HostingAdvice.com): Boasting market-leading VPS hardware, slick management software, and free SSD drives and backups, InMotion Hosting competes to win when it comes to managed VPS hosting packages. The host initiates its VPS customer relationship with free website migrations and up to two hours of launch assistance from an experienced sysadmin. Go to full review »

Setup Time Disk Space CPU RAM
6 minutes 90 GB SSD – 360 GB SSD 4 – 16 cores 4 GB – 16 GB

InterServer.net

InterServer Review

Monthly Starting Price $6.00

  • $0.01 for the first month using code HOSTINGADV
  • Then $6 monthly with no contracts, no changes
  • Latest of PHP, MySQL, Perl, Python, and Ruby
  • 7 operating system options for Linux or Windows
  • Full root access and choice of datacenter
  • Get started on InterServer now.

VPS
RATING
4.7 ★★★★★ Our Review

InterServer: Our Expert’s Review

Laura Bernheim (HostingAdvice.com): InterServer’s on-site datacenter and hands-on involvement with configuring and provisioning virtual private servers give customers a level of flexibility not seen with many other hosting providers. InterServer rations VPS and cloud resources through slices. Go to full review »

Setup Time Disk Space CPU RAM
6 minutes 30 GB SSD – 480 GB SSD 1 – 16 CPUs 2 – 32 GB

What is Node.js?

The open-source Node.js framework largely replaced AJAX and became a major part of web and mobile app development thanks to the ability to offer an asynchronous event-driven JavaScript runtime at scale.

Node.js is a development framework that allows JavaScript to run on a web server across Windows, Linux, and macOS hardware.

Node.js includes port configuration for applications that maintains an active connection between the web server and user’s browser. This enables dynamic updated information on web pages without needing to reload.

Major companies, including GoDaddy, IBM, LinkedIn, Microsoft, PayPal, and Amazon Web Services, all leverage Node.js in production.

Node.js operates with event loops, callbacks, and data streaming with low latency for transfers.

Ryan Dahl invented Node.js in 2010, then went on to found the Deno project with similar fundamentals.

JavaScript and TypeScript development has surged based on Node.js adoption and is commonly used with app construction solutions such as React, Vue, Gatsby, NEXT, and Nuxt.

How Do I Check My Node.js or NPM Version?

To check your Node.js version on Linux, connect to the server with an SSH connection using PuTTy or a similar tool and run the command:

node -v

Windows users can run the same command in PowerShell. macOS users can access the Terminal from the Launchpad for command line queries.

To check the currently installed npm version, use the same tools to run the npm -v command.

Why Should I Update Node.js?

Each Node js release provides information about features, integrations, and runtime compatibility for applications that is essential for developers.

If you use a different version of Node js than the current release, there can be a security risk because of unpatched vulnerabilities.

It is important not to rely on a specific version of Node js, but keep your web server continually updated with the latest NodeJS version for cybersecurity.

If you are not sure about the version number of NodeJS that is installed on the web server, use the commands in this tutorial to test and configure the hardware.

If you use Visual Studio or Docker for development, it is easy to install NodeJS with version control automation for upgrades across development environments.

Make sure the version number of Node js is standardized for testing new feature compatibility.

How Often Should I Update Node.js?

Installing a newer version of Node JS rarely breaks existing code but should be tested in sandbox environments before going live with changes just to be safe.

Replacing the current version of Node JS with a newer version may also require some refactoring of software application code.

The current version of Node JS can change multiple times per week as the framework is in active development with thousands of programmers working on the project.

Multiple NodeJS versions can be managed on a web server with cPanel or using subdomains. The NPM package manager will archive all previous version releases of Node JS with binary packages that can be installed at any time you need to revert changes.

We recommend updating Node JS as soon as the latest stable version is released to keep your code up to date to support new features.

If you rely on a specific version of Node JS, you may have problems with managing dependencies and patching security holes over time.

Summary: Updating Node.js to the Latest Version

It is not difficult to learn how to update Node js to the latest version if you are familiar with using command line tools for web server administration.

Web hosts that install NodeJS in advance on a server and allow you to select the best NodeJS version for your apps.

If you need a NodeJS v16 installation for application compatibility, these tools make it easier to manage multiple versions. But we recommend most users to install the latest stable version.

You can use many of the same processes to update other packages with npm. This related post will explain how to install a different npm version or multiple NodeJS versions for various dependencies.

You can revert to the previous version of a NodeJS application with LTS version control using nvm command tools with active LTS and a PackageJSON file.

Updating a NodeJS app and npm is just the beginning. You’ll want to keep the rest of your packages and dependencies secure as well.

Always rely on the newer version of Node js for access to the new feature development and security. The latest version of Node.js is essential to keep up to date, maximize compatibility, and maintain security on the current version of your apps.

The npm package manager solution will allow you to extend a Node application with code from open source projects to get the most benefit from the app development framework.

Advertiser Disclosure

HostingAdvice.com is a free online resource that offers valuable content and comparison services to users. To keep this resource 100% free, we receive compensation from many of the offers listed on the site. Along with key review factors, this compensation may impact how and where products appear across the site (including, for example, the order in which they appear). HostingAdvice.com does not include the entire universe of available offers. Editorial opinions expressed on the site are strictly our own and are not provided, endorsed, or approved by advertisers.

Our Editorial Review Policy

Our site is committed to publishing independent, accurate content guided by strict editorial guidelines. Before articles and reviews are published on our site, they undergo a thorough review process performed by a team of independent editors and subject-matter experts to ensure the content’s accuracy, timeliness, and impartiality. Our editorial team is separate and independent of our site’s advertisers, and the opinions they express on our site are their own. To read more about our team members and their editorial backgrounds, please visit our site’s About page.