How to Update Node.js on Linux, macOS, and Windows
Traducciones al EspañolEstamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.
Node.js is a cross-platform runtime environment for server-side JavaScript applications. Node.js uses the V8 JavaScript engine and is very popular. It is regularly updated for security and improvements, and should be kept updated on your systems.
Before You Begin
This guide assumes you are already running Node.js on your Linode or local workstation and are updating the version. If you don’t have it installed, see the How to Install Node.js guide.
Install NPM, which installs by default with Node.js.
This guide assumes you are only updating your version of Node.js and aren’t looking to run multiple versions. If you do, see the guide How to Install and Use the Node Version Manager.
Update your Linode’s system: sudo apt-get update && sudo apt-get upgrade
Update your local workstation’s system using the tools and package managers for the operating system.
If you’re using the installer to update, go to the Node.js downloads page to get the appropriate version. The most recent version of long-term support (LTS) is listed and you also have the option to choose a version in the Current section.
NoteCurrent is for developers and development or testing environments that don’t require the systems to be as stable or up and accessible. LTS is aimed at production environments that require stability and continued uptime. If you are unsure which you need, choose LTS.
Updating the Node.js version using NPM
NPM is installed by default with Node.js and is the easiest way to update to any new version on Linux, macOS, or Windows when you do not need to use multiple versions.
Open the Terminal on Linux or macOS. On Windows, launch the Windows PowerShell as an administrator. Search for it in the search bar and then either right-click or click on the arrow to the right and choose Run as Administrator.
Enter the command
npm install -g n
to install then
module, a Node.js version manager.Now that
n
is installed, entern stable
in the Terminal or PowerShell to install the stable version of Node.js- You can also use
n latest
for the most recent version, orn [version number]
if you have a specific version you need to install.
- You can also use
Agree to any prompts that appears.
When the installation is complete, check the version installed with
node -v
.Close the Terminal or PowerShell when finished.
Updating the Node.js version using NVM
If you need to install NVM, see our guide How to Install and Use the Node Version Manager. It’s a useful tool to have, especially in a development environment or if you have to use multiple versions of Node.js.
Open the Terminal on Linux or macOS. On Windows, launch the Windows PowerShell as an administrator. Search for it in the search bar and then either right-click or click on the arrow to the right and choose Run as Administrator.
If you only need the most recent stable version, enter the command
nvm ls stable
.- If you need something other than the stable version:
a. Enter the command
nvm ls
to check what version you have. d. Enter the commandnvm ls -remote
to see what versions are available. Note the one you need. c. Enter the commandnvm install [version number]
- If you need something other than the stable version:
a. Enter the command
Agree to any prompts that appears.
When the installation is complete, check the version installed with
nvm ls
.Close the Terminal or PowerShell when finished.
Updating the Node.js version on macOS
Using Homebrew
If you installed Node.js using Homebrew, then updating is easy.
Open the Terminal.
Enter the command
brew update
and agree to any prompts.Enter the command
brew upgrade node
and agree to any prompts.Quit the Terminal when finished.
Using the Node.js Installer
Open the installer from your Downloads folder and click Continue.
If you agree with it, accept the license by clicking Continue and Agree.
If you need to change the installation location, do so. Also, if you want to customize the installation, choose Customize. Linode recommends using the Standard Installation. Click Continue.
The installation is finished. Click Close and macOS moves the installer to the Trash.
Updating the Node.js version on Windows
Using Chocolatey
Assuming you installed Chocolatey when originally installing Node.js, updating should move quickly. Otherwise, update using the following installer instructions.
Launch the Windows PowerShell as an administrator. Search for it in the search bar and then either right-click or click on the arrow to the right and choose Run as Administrator.
When the command prompt loads, enter the following command:
choco upgrade nodejs.install
Accept any prompts that requires permission.
Close PowerShell when finished.
Using the Node.js Installer
Open the installer from your Downloads folder and click Next.
If you agree with it, accept the license by checking the box next to I accept the terms in the License Agreement and click Next.
If you need to change the installation location, do so now and click Next.
Choose the packages to install Linode recommends all of them, which is the default. You are prompted to check a box to Automatically install the necessary tools. Do so and click Next.
After installation is complete move the installer to the Recycle Bin.
More Information
You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.
This page was originally published on