Node.js + Windows Subsystem for Linux

Build, run, and debug Node.js apps natively on WSL

Combine Linux performance with Windows tooling. This guide walks you through installing Node.js with modern version managers, configuring your editor, and shipping production-ready services from the WSL terminal.

  • 1Prep your distro for Node.js with build-essential packages and shell tweaks.
  • 2Install and switch between Node.js versions using nvm, fnm, or asdf.
  • 3Wire up VS Code debugging, package managers, and test runners for a polished workflow.
WSL Terminal~/workspace
user@wsl:~$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
user@wsl:~$ source ~/.nvm/nvm.sh
user@wsl:~/app$ nvm install --lts
user@wsl:~/app$ npm run dev

Prefer a GUI? Pair this workflow with VS Code remote development or use WSLg for GPU-accelerated browser previews.

Prerequisites

Start with a healthy WSL distro (Ubuntu, Debian, Arch, etc.). Run these checks inside your WSL terminal before installing Node.js.

Verify WSL Distro

Confirm that your Linux distribution is running with WSL 2 for best Node.js performance.

bash
wsl -l -v

Update Packages

Refresh the package index and upgrade existing packages inside your distro.

bash
sudo apt update && sudo apt upgrade

Install Build Essentials

Install required build tooling so native node modules compile correctly.

bash
sudo apt install build-essential curl file git

Install Node.js with a Version Manager

Avoid using the system node package. Version managers keep projects isolated and simplify upgrades.

nvm

The most popular Node.js version manager. Great when you need to switch between LTS releases.

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

Common commands

  • nvm install --lts
  • nvm use --lts
  • nvm install 22.11.0

fnm

Fast Node Manager written in Rust. Excellent performance with minimal shell init cost.

bash
curl -fsSL https://fnm.vercel.app/install | bash

Common commands

  • fnm env --use-on-cd >> ~/.bashrc
  • fnm install latest
  • fnm use 20

asdf

Polyglot version manager that can handle Node.js plus other runtimes from a single tool.

bash
asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git

Common commands

  • asdf install nodejs latest
  • asdf global nodejs 20.12.2

Tooling Recommendations

Package Managers

  • npm ships with Node.js—great for simple scripts and smaller projects.
  • pnpm uses content-addressable storage for faster installs across repos.
  • Yarn 4 (Berry) improves monorepo workflows and zero-install environments.

Task Automation

  • Use npm scripts for lightweight automation directly in package.json.
  • Adopt turbo, Nx, or just-task if you orchestrate multi-package workspaces.
  • Leverage VS Code tasks.json for shared dev/CI tasks accessible from the command palette.

Testing & Linting

  • Vitest or Jest cover unit/integration testing with snapshot support.
  • ESLint handles linting; pair with Prettier or Biome for formatting.
  • Consider Playwright for full-stack browser automation on WSL.

Debugging Node.js in WSL

VS Code Debug Adapter

Install the "Node.js" debugger in VS Code, then use Run and Debug ➜ Node.js Launch to set breakpoints inside your WSL workspace.

Inspect CLI

Launch node with --inspect or --inspect-brk, then attach Chrome DevTools at chrome://inspect or the VS Code debugger.

pnpm + Turbo Logs

When commands run inside pnpm / turbo pipelines, stream logs with pnpm --reporter=append-only for deterministic CI output.