---
title: "Node.js"
description: "Install fnm inside WSL and use it to install Node.js LTS, with automatic version switching per project."
canonical_url: "https://vinicunca.dev/windows-dev/guide/nodejs"
---
# Node.js

> Install fnm inside WSL and use it to install Node.js LTS, with automatic version switching per project.

Install Node.js **inside WSL**, not on Windows. VS Code's WSL extension and every `npm` / `pnpm` script should see the Linux binary.

This guide uses [fnm](https://github.com/Schniz/fnm) (Fast Node Manager): a single Rust binary that reads `.nvmrc`, `.node-version` and `package.json` `engines`. It is faster than nvm and does not need to be sourced as a shell function.

`curl` and `unzip` are required. The [zsh step](https://vinicunca.dev/windows-dev/guide/zsh) already installed both.

## Install fnm

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

The installer puts the binary in `~/.local/share/fnm` and appends a loader to `~/.zshrc`. Replace that loader with the version that switches Node when you `cd` into a project:

```bash [~/.zshrc]
# fnm
export PATH="$HOME/.local/share/fnm:$PATH"
eval "$(fnm env --use-on-cd --shell zsh)"
```

Reload:

```bash
source ~/.zshrc
fnm --version
```

## Install Node.js LTS

As of October 2026, Active LTS is the **24.x** line. Do not pin a patch in your notes; let fnm pick the current LTS:

```bash
fnm install --lts --use
fnm default lts-latest
node -v
npm -v
```

`fnm install --lts` aliases that version as `lts-latest`. `fnm default lts-latest` is what new shells use when a project does not specify a version.

## Everyday commands

```bash
fnm ls                  # installed versions
fnm ls-remote --lts     # available LTS releases
fnm install 22          # another major (for example Maintenance LTS)
fnm use 24              # this shell only
fnm default 24          # new shells
fnm uninstall 22
```

Drop a `.node-version` (or `.nvmrc`) in a repo so `--use-on-cd` selects that version when you enter the directory:

```bash
echo 24 > .node-version
```

## Why not nvm or a Windows installer?

- **nvm** works, but it is a shell script you `source` on every prompt. fnm is a binary and starts faster. If a teammate's README says `nvm use`, fnm still honors `.nvmrc`.
- **The Windows Node.js installer** puts `node` on the Windows `PATH`. Mixing that with WSL leads to wrong binaries, CRLF scripts and native-addon mismatches. Uninstall it if it is already there (`winget uninstall -e --id OpenJS.NodeJS.LTS`).

> [!NOTE]
> 
> Corepack is **not** how this guide installs pnpm. Node.js 25 and later no longer ship Corepack at all, and on 24 it is still experimental. The [next step](https://vinicunca.dev/windows-dev/guide/pnpm) uses pnpm's standalone installer.

---

- [fnm](https://github.com/Schniz/fnm)


## Sitemap

See the full [sitemap](https://vinicunca.dev/sitemap.md) for all pages.
