How to Switch Node.js Version in WSL Ubuntu

Developers often need to manage multiple Node.js versions on their systems to work on different projects or ensure compatibility with specific applications. Fortunately, with the help of Node Version Manager (nvm), switching between Node.js versions in your Windows Subsystem for Linux (WSL) Ubuntu environment is simple. This guide will help you set up and make a specific Node.js version (e.g., v20.12.2 latest LTS) the default in your WSL Ubuntu for seamless development.


  • Ensure that both WSL and Ubuntu are set up on your Windows 10 or Windows 11 machine. If you haven’t done so already, you can install WSL by following Linuxbeast official guide.
  • If Node.js is not installed yet, the initial steps will help you get it ready.

Step 1: Install nvm

First, let’s install Node Version Manager (nvm), which will enable us to manage Node.js versions easily.

curl -o- | bash

This command will download and run the nvm installation script, setting up nvm on your WSL Ubuntu.

Step 2: Activate nvm

To use nvm, you need to close and reopen your terminal session. This step ensures that nvm is loaded correctly into your shell.

Step 3: Check Available Node.js Versions

With nvm installed, you can now check the available Node.js versions:

nvm ls-remote

This will display a list of all the Node.js versions available for installation. Look for version v20.12.2 (Latest LTS: Iron) in the list.

Step 4: Install Node.js v20.12.2

Now that you know v20.12.2 is available, you can install it using the following command:

nvm install v20.12.2

This will download and install Node.js v20.12.2 in your WSL Ubuntu environment.

Step 5: Set Node.js v20.12.2 as the Default Version

To ensure that Node.js v20.12.2 is the default version for your development needs, set it as the default using the alias command:

nvm alias default v20.12.2

This will make v20.12.2 the default Node.js version for any new terminal sessions.

Final Step: Verify the Installation

To verify that Node.js v20.12.2 has been installed successfully, run:

node -v

This command will display the version number, and you should see v20.12.2 in the output.


Congratulations! You have successfully switched your Node.js version in your WSL Ubuntu environment to v20.12.2 latest LTS using Node Version Manager (nvm). Now you can enjoy working on your projects using the latest Node.js version without any compatibility issues. Remember that you can always switch between different Node.js versions using nvm use <version> whenever required.

Happy coding!

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.