To update Node.js on Windows, there are a few different methods you can use. Here’s a guide for each approach:
Method 1: Using the Node.js Installer (Recommended)
- Download the Latest Installer:
- Go to the Node.js website.
- Download the latest version for Windows. Make sure to select the installer for your system architecture (e.g., 64-bit).
- Run the Installer:
- Double-click the downloaded installer file.
- Follow the prompts to complete the installation.
- The installer will replace the current Node.js version with the latest one.
- Verify the Update:
- Open a Command Prompt or PowerShell window.
- Run the following command to check the installed version:bashКопировать код
node -v
- This should show the new version number.
Method 2: Using nvm-windows
(Node Version Manager for Windows)
nvm-windows
allows you to manage multiple versions of Node.js on a single machine.
- Install nvm-windows:
- Download the latest
nvm-windows
installer from the nvm-windows GitHub page. - Run the installer and follow the prompts.
- Download the latest
- Install the Latest Version of Node.js:
- Open a Command Prompt or PowerShell window.
- Run the following commands:
nvm install latest nvm use latest
- Verify the Update:
- Check the installed version with:
node -v
- Check the installed version with:
- Switch Between Versions (optional):
- If you want to switch between different Node.js versions, you can do so with:
nvm use <version>
- For example:bashКопировать код
nvm use 14.17.0
- If you want to switch between different Node.js versions, you can do so with:
Method 3: Using npm
(Node Package Manager)
If you already have npm
installed, you can update Node.js with the n
package (Node version manager).
- Install
n
Globally:- Open Command Prompt or PowerShell as an administrator.
- Run:
npm install -g n
- Update Node.js to the Latest Version:
- Run the following command to install the latest version of Node:
n latest
- Run the following command to install the latest version of Node:
- Verify the Update:
- Check the new Node version with:
node -v
- Check the new Node version with:
Note: n
is mainly designed for Unix-based systems, so this approach may not work as smoothly on Windows.
Method 4: Update Through Chocolatey (if you installed Node via Chocolatey)
If you used the Windows package manager Chocolatey to install Node.js, you can update it through Chocolatey.
- Update Node.js via Chocolatey:
- Open Command Prompt or PowerShell as an administrator.
- Run the following command:
choco upgrade nodejs
- Verify the Update:
- Check the installed version:
node -v
- Check the installed version:
These methods should help you successfully update Node.js on a Windows system. The Node.js installer and nvm-windows
are generally the most straightforward methods.