How to Update Node to Another Version on Windows WSL


I started using some libraries that required updated versions of Node.js.

It’s a fairly simple process to update.

Before anything, let’s check our node version.

node -v

Using npm

We can use npm to update node.

First, we’ll clear the cache and install the n module.

npm cache clean -f
npm install -g n

We can now use n to update node. We can use any of the following commands.

n stable # Latest stable release
n latest # Latest release
n [version.number] # Specific version: n 14.16.0

Using nvm

We can also use nvm to update node.

Let’s install nvm using the curl command. This will install to ~/.nvm.

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

Afterwards, we must either restart the terminal, or source our shell’s respective run commands.

source ~/.bashrc # bash
source ~/.zshrc # zsh
. ~/.profile # ksh

We can verify our installation with nvm --version.

Finally, let’s use nvm to install the version we want. We can use nvm ls-remote to view all available releases.

nvm install [version.number] # nvm install v14.16.0