How to Install NodeJs and npm on WSL?
Learn how to install Node.js and npm on Windows Subsystem for Linux (WSL) with a simple step-by-step guide. This tutorial shows how to set up a modern Node.js development environment inside WSL using Ubuntu, verify the installation, and start building JavaScript applications on Windows with a full Linux toolchain.

Introduction
Developers working on Windows often need access to the powerful tools available in the Linux ecosystem. This is where Windows Subsystem for Linux (WSL) becomes extremely useful. WSL allows you to run a real Linux environment directly inside Microsoft Windows without requiring a virtual machine or a dual-boot setup. With WSL, developers can use familiar Linux tools, package managers, and workflows while continuing to work from their Windows desktop.
For JavaScript developers, setting up a reliable development environment is essential. Technologies like Node.js and its package manager npm are fundamental for building modern web applications, APIs, and development tools. Installing them inside WSL allows developers to work with a Linux-based development toolchain while keeping the convenience of a Windows system. This setup closely resembles real production environments, since many servers and cloud platforms run Linux.
At Linux City Stories, we explore practical workflows that combine the power of Linux with modern development needs. WSL provides a bridge between these worlds, making it easier for developers to experiment, learn, and build software using a genuine Linux environment without leaving their primary operating system.
Note:
Although this guide demonstrates the installation process inside WSL, the same method works on most Linux distributions as well, since WSL provides a standard Linux user environment.
Installing NVM on WSL (Ubuntu)
To manage different versions of Node.js easily, it is recommended to install Node.js using Node Version Manager (NVM). NVM allows developers to install, switch, and manage multiple Node.js versions without conflicts. This is particularly useful when working on projects that require different Node versions.
The official installation script for NVM is available on its GitHub repository. To install it on your Ubuntu environment inside Windows Subsystem for Linux, you can download and run the installer using curl.
The installation command looks like this:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bashThis command performs two actions:
Downloads the installation script using
curlPipes the script into
bashso it executes automatically
However, before running any remote script directly in your terminal, it is always a good practice to inspect the script first. You can do this by removing the | bash portion of the command:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.shWhen you run this command, the terminal displays the full installation script. This may result in a large amount of output, sometimes hundreds or thousands of lines, because you are viewing the raw script instead of executing it.
After verifying that the script is safe to run, you can execute the installation using the piped command:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bashDuring installation, NVM downloads its repository and installs it inside the .nvm directory in your home folder. The installer also updates your .bashrc file so that NVM loads automatically whenever a new terminal session starts.
After the installation completes, you may see instructions similar to the following:
=> Close and reopen your terminal to start using nvmInstead of reopening the terminal, you can activate NVM immediately in the current session by running:
source ~/.bashrcThis command reloads your shell configuration and makes the nvm command available instantly.
Once this step is complete, your WSL environment is ready to install and manage Node.js versions using NVM.
Choosing a Node.js Version with NVM
After installing Node Version Manager, you can view all available Node.js versions by running:
nvm list-remoteThis command displays a large list of Node.js releases that can be installed. The list typically includes:
Current releases
Older versions
LTS (Long Term Support) versions
Because Node.js is actively developed, this list can contain many versions.
When reviewing the list, you may notice that certain versions are labeled as LTS. For example:
v24.14.0 (Latest LTS: Krypton)In most situations, you should install the Latest LTS version rather than the newest experimental release.
Why Choose the LTS Version?
Long Term Support (LTS) versions of Node.js are recommended for general development and production use because they:
Receive long-term maintenance and security updates
Are widely tested and considered stable
Have better compatibility with popular frameworks and libraries
Are commonly used in production environments
Non-LTS versions, often called current releases, usually contain the newest features but may not receive long-term maintenance. These versions are typically used for testing new capabilities rather than for long-term projects.
Installing the Latest LTS Version
To install the latest LTS version with NVM, run:
nvm install --ltsThis command automatically downloads and installs the most recent LTS release without requiring you to specify a version number.
You can also install a specific version if required:
nvm install 24.14.0After installation, activate the installed version with:
nvm use --ltsFinally, verify that Node.js is installed correctly:
node -vUsing the LTS version ensures that your development environment remains stable, secure, and compatible with most Node.js tools and frameworks.
Conclusion
Setting up Node.js and npm inside Windows Subsystem for Linux is a simple yet powerful way to create a Linux-based development environment while working on Microsoft Windows. By using Node Version Manager (NVM), developers gain the flexibility to install, switch, and manage multiple Node.js versions without affecting other projects or system configurations.
In this tutorial, we covered installing NVM, verifying the installation, viewing available Node.js versions, and selecting a stable LTS release for development. Choosing the LTS version helps ensure compatibility with libraries, improved stability, and long-term security updates.
With Node.js and npm properly installed in WSL, you now have a development environment that closely resembles a real Linux server setup. This makes it easier to build, test, and deploy modern JavaScript applications with fewer environment-related problems.
At Linux City Stories, the goal is to explore practical Linux workflows that make development simpler and more accessible. WSL provides an excellent bridge between Windows and Linux, allowing developers to experience the power of Linux tools without leaving their primary operating system.
Your Node.js environment is now ready — you can start creating applications, installing packages, and exploring the vast JavaScript ecosystem.
Enjoyed this post?
Follow Linux City Stories to get notified of new posts.
Do you intend to write blog posts yourself?
Click hereHave a Question?
Please log in to ask the author directly.
Comments
No comments yet. Be the first to share your thoughts!
