To update Node.js on Windows, the most reliable method is to download the latest installer from the official website and run it, as Windows does not have a built-in update command for Node.js. While some users attempt to use third-party tools like n or nvm-windows, the official installer automatically detects existing versions and replaces them with the new version while preserving your global npm packages.

What You'll Need

  • A computer running Windows 10 or 11.
  • An active internet connection to download the installer.
  • Administrator privileges on the machine to allow the installer to modify system files and environment variables.
  • A command line interface, such as Command Prompt (cmd) or PowerShell, to verify the current and updated versions.

Step-by-Step

  1. Check your current version: Open the Command Prompt or PowerShell. Type node -v and press Enter. This will display your current version (e.g., v18.15.0). Note this version so you can confirm the update was successful later.
  2. Visit the official website: Open your web browser and go to nodejs.org. The homepage will typically present two primary options: the LTS (Long Term Support) version and the Current version.
  3. Choose the correct version: For most users, the LTS version is recommended because it is more stable and supported for a longer period. The Current version contains the latest features but may be less stable. Click the button for the version you prefer to download the .msi installer file.
  4. Run the installer: Locate the downloaded .msi file in your Downloads folder and double-click it to launch the installation wizard.
  5. Follow the setup wizard: Click Next through the welcome screen. Accept the license agreement by checking the box and clicking Next.
  6. Select installation location: The installer will suggest a default directory (usually C:\Program Files\nodejs). It is highly recommended to leave this as the default to avoid path conflicts. Click Next.
  7. Custom Setup: You will see a list of features to be installed, such as the Node.js runtime, npm (Node Package Manager), and the Add to PATH option. Ensure that "Add to PATH" is selected, as this allows you to run Node commands from any terminal window. Click Next.
  8. Tools for Native Modules: The installer may ask if you want to install "Tools for Native Modules" (which includes Python and Visual Studio Build Tools). If you plan to use modules that require compilation (like some database drivers or encryption libraries), check this box. If you are a beginner or only using basic JavaScript packages, you can skip this to save disk space. Click Next.
  9. Complete installation: Click Install. A User Account Control (UAC) prompt will appear asking for permission to make changes to your device; click Yes. Once the progress bar completes, click Finish.
  10. Restart your terminal: This is a critical step. If you had a Command Prompt or PowerShell window open during the installation, it will not recognize the new version because the environment variables are loaded when the terminal starts. Close all open terminal windows and open a new one.
  11. Verify the update: In the new terminal window, type node -v again. The output should now reflect the version number of the installer you just ran.
  12. Update npm: Node.js comes bundled with npm, but npm is often updated more frequently than Node itself. To ensure you have the latest package manager, type npm install -g npm@latest and press Enter.

Common Mistakes

One of the most frequent mistakes users make is attempting to use the n module to update Node on Windows. The n package is designed specifically for POSIX systems (Linux and macOS) and does not function on Windows. Attempting to run it usually results in shell errors or a failed installation. Always use the official installer or a Windows-specific version manager.

Another common error is forgetting to restart the terminal. Many users run the installer, go back to their already-open PowerShell window, type node -v, and see the old version. This leads them to believe the installation failed, when in reality, the terminal is simply using the cached path from before the update.

Some users also try to manually delete the Node.js folder in Program Files before running the new installer. This is unnecessary and can sometimes leave orphaned registry keys or broken environment variables. The official installer is designed to handle the overwrite process cleanly.

Tips

If you are a professional developer working on multiple projects, consider using nvm-windows (Node Version Manager for Windows). Unlike the standard installer, NVM allows you to install multiple versions of Node.js on the same machine and switch between them with a single command. This is invaluable when one project requires Node 14 and another requires Node 20.

When updating, always prioritize the LTS version unless you specifically need a feature found only in the Current release. LTS versions undergo rigorous testing and are the standard for production environments, ensuring that your applications don't break due to unexpected API changes.

Keep an eye on your global packages. While updating Node usually preserves global modules, occasionally a major version jump (e.g., v16 to v20) can cause some global packages to stop working. If a global tool fails after an update, try reinstalling it using npm install -g [package-name].

Troubleshooting

If the node -v command returns an error saying "'node' is not recognized as an internal or external command," the most likely cause is that Node.js was not added to your system's PATH environment variable. To fix this, search for "Edit the system environment variables" in the Windows Start menu. Click Environment Variables, find the "Path" variable under System Variables, click Edit, and ensure C:\Program Files\nodejs\ is listed. If it is missing, add it manually and restart your computer.

If the installer hangs or throws an error during the "Installing" phase, check if any Node.js processes are still running in the background. Open the Task Manager (Ctrl+Shift+Esc), look for any processes named "node.exe," end those tasks, and try running the installer again as an Administrator.

In cases where the update seems to have worked but you are experiencing strange crashes with your projects, try clearing the npm cache. Run npm cache clean --force in your terminal. This removes temporary files that might be conflicting with the new Node.js runtime version.

If you encounter a permission error when updating npm globally (e.g., EACCES or PERM errors), ensure you are running your terminal as an Administrator. Right-click the Command Prompt icon and select "Run as administrator" before executing the npm install -g npm@latest command.

Frequently Asked Questions

Can I update Node.js using a command like apt-get or brew on Windows?

No, Windows does not have a native package manager like apt or Homebrew that is installed by default for Node.js. While Windows Package Manager (winget) exists, the official recommended method is the .msi installer or NVM-Windows.

Will updating Node.js delete my project files?

No, updating the Node.js runtime only changes the engine that executes your code. Your project folders, package.json files, and local node_modules folders remain untouched.

What is the difference between the LTS and Current versions?

LTS stands for Long Term Support and is designed for stability and reliability. The Current version contains the latest features and experimental updates but may be updated more frequently and could introduce breaking changes.

Do I need to uninstall the old version before installing the new one?

No, you do not need to uninstall the previous version. The official Node.js installer will automatically detect the existing installation and upgrade it to the new version.

Why is my npm version different from my Node version?

Node.js and npm are separate tools, although they are distributed together. Node is the runtime environment, and npm is the package manager. They have their own independent versioning systems.