TechEarl

How to Install Node.js on Linux, macOS, and Windows

How to install Node.js the right way on Linux, macOS, and Windows. Covers nvm, fnm, Volta, the official nodejs.org installer, apt/dnf via NodeSource, Homebrew, winget, Chocolatey, Docker, and how to verify the install.

Ishan KarunaratnePublished ⏱️ 18 min readUpdated
Share thisCopied
Installing Node.js on Linux, macOS, and Windows using a version manager and the official installer, with node --version verifying a fresh install

To install Node.js, use a version manager. On Linux or macOS, install fnm with curl -fsSL https://fnm.vercel.app/install | bash, then run fnm install --lts. On Windows, winget install Schniz.fnm followed by the same command. Otherwise download the LTS installer from nodejs.org. Verify with node --version in a fresh terminal. Choose LTS, not Current.

Installing Node.js is genuinely simple, but the best way to install it depends on the machine: on a development laptop you almost always want a version manager (so you can hold several Node majors side by side and never need sudo for a global package), whereas on a single-purpose server or a locked-down work laptop the official installer or your OS package manager is the pragmatic choice. I have set Node up on my own machines, on production boxes, and inside CI more times than I can count, and the one mistake that bites people is reaching for apt install nodejs on day one and ending up stuck on a version that is a year behind. Below is how to install Node.js on each OS the way I actually do it, with the verification step and the most common first-install snags.

Latest LTS
26.13.1

Long-Term Support: the version to use in production.

Next major (pre-release)
27.0.0-alpha.0.2.0

Not a stable release. There is no Current line until this major ships, so use LTS.

How do I install Node.js?

The fastest reliable way to install Node.js is with a version manager. On Linux or macOS, install fnm (curl -fsSL https://fnm.vercel.app/install | bash), then fnm install --lts and fnm use lts-latest. On Windows, winget install Schniz.fnm then the same fnm install --lts. If you do not want a version manager, download the LTS installer from nodejs.org/en/download and run it (Windows .msi, macOS .pkg; on Linux the download is a binary tarball you extract, not an installer). On Ubuntu/Debian use NodeSource (curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - && sudo apt-get install -y nodejs) rather than the stale distro nodejs package. On macOS Homebrew, brew install node. After any method, verify with node --version and npm --version in a fresh terminal. Choose LTS, not Current, unless you have a specific reason to be on the bleeding edge.

Jump to:

LTS vs Current: which one to install

Node.js ships two release lines at once, and picking the wrong one is the most common first-install misstep:

LineWhat it meansWhere things stand on 24 November 2026
Active LTSInstall this for anything real: apps, libraries, productionNode 26 (Lithium), Active LTS since 28 October 2026
Maintenance LTSFine if you are already on it. Critical fixes and security onlyNode 24 (Krypton) until 30 April 2028, Node 22 (Jod) until 30 April 2027
CurrentNew V8 and language features land here firstNone right now. Node 27 is in Alpha and is scheduled to become Current on 22 April 2027
End of lifeDo not install these. No security patches at allNode 20, 21, 23 and 25

Through Node 26, a major ships in April or May as Current, and even-numbered majors are promoted to Active LTS that October. Support runs about 36 months from release, roughly 12 months Active and then about 18 months Maintenance. Starting with Node 27 the cycle is annual: one major a year, and every major moves to LTS after six months as Current, so the old "even numbers are LTS" shortcut stops working.

Pick LTS, which today means Node 26. Almost every npm library declares engines.node ranges that target LTS, and the Active LTS line gets the longest support window. If a tutorial tells you to install Node 20, it predates April 2026 and that release is now end of life. The live card above pulls the exact LTS number from the Node.js release feed, and labels the Node 27 alpha as a pre-release rather than a Current release. If you want the full breakdown of the release lines and when each one matters, Node.js LTS vs Current goes deeper than this summary.

Which installation method should I use?

For a development machine, the best way to install Node.js is a version manager: fnm on Linux, macOS, or Windows, or nvm on Linux and macOS. Both install Node.js under your home directory with no sudo and let you switch versions per project. Use the official nodejs.org installer or NodeSource on servers and locked-down machines, and a node: base image in Docker.

MethodPlatformsMultiple versions?Needs sudo/admin?Best for
fnmLinux, macOS, WindowsYesNoModern default; fast, cross-platform
nvmLinux, macOSYesNoThe most-documented option (Bash script)
VoltaLinux, macOS, WindowsYes (repo-pinned)NoExisting Volta setups only; the project is unmaintained and points new users to mise
nodejs.org installermacOS, Windows (Linux gets a binary archive to extract)NoYesLocked-down or single-purpose machines
NodeSource (apt/dnf)LinuxNoYesServers, Docker, current versions from a repo
HomebrewmacOS, LinuxLimitedNoMac devs already living in brew
winget / ChocolateyWindowsNoYesWindows machines, scripted provisioning
DockerAnywherePer imageNoContainers; "install" means the FROM line

If you only take one recommendation: use fnm on a personal machine, fnm or mise on a team repo, and the official installer or NodeSource where you cannot install a version manager. I used to suggest Volta for teams. Its README now opens with "Volta is unmaintained" and recommends migrating to mise, so I would not start a new setup on it.

Install on Linux (Ubuntu, Debian, Fedora, RHEL)

Do not use the distro's own nodejs package as your first move. Ubuntu's apt repo, for example, often ships a Node major that is well behind the current LTS, and you cannot easily switch off it later. Use NodeSource, which mirrors the official release line.

Ubuntu / Debian (apt):

bash
# Latest LTS
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejs

# Or a specific major (e.g. Node 22)
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt-get install -y nodejs
A live terminal confirming a Node install: node --version, npm --version, and which node.
A live terminal: confirming the Node and npm versions after install.

Fedora / RHEL / Rocky / Alma (dnf):

bash
curl -fsSL https://rpm.nodesource.com/setup_lts.x | sudo bash -
sudo dnf install -y nodejs

NodeSource installs npm alongside Node, so you do not need a separate npm package (and on Debian/Ubuntu installing the distro npm separately can actually conflict). Verify with node --version && npm --version.

If you would rather not pipe a script into bash as root (a fair instinct on a shared server), install fnm under your own user instead, see the version-manager section below. It needs no root and gives you version switching for free.

Install on macOS

Two good options on macOS: Homebrew, or a version manager.

Homebrew (simplest if you already use brew):

bash
brew update
brew install node          # latest stable
brew install node@24       # a specific major
node --version

Homebrew's node formula tracks the latest stable release, which can be a Current major rather than LTS. Today it is Node 26, the Active LTS. If you need to stay on an older LTS line, install the pinned formula (node@24) and brew link it. Homebrew deprecated node@22 on 30 October 2026 because that line is in maintenance, so do not start there.

fnm via Homebrew (my preference, gives you version switching):

bash
brew install fnm
echo 'eval "$(fnm env --use-on-cd)"' >> ~/.zshrc
source ~/.zshrc
fnm install --lts
fnm use lts-latest

The macOS .pkg from nodejs.org is also a perfectly good choice and is a Universal binary, running natively on both Apple Silicon and Intel. See the official-installer section.

Install on Windows

Windows has more options than the other platforms because the original Unix nvm does not run there. Pick one and stick to it; mixing two Node installers on Windows is the fastest route to "which node.exe is on PATH" confusion.

ToolInstall commandVersion switching?
fnmwinget install Schniz.fnmYes (best modern choice)
wingetwinget install OpenJS.NodeJS.LTSNo
Chocolateychoco install nodejs-ltsNo
nvm-windowsfrom coreybutler/nvm-windowsYes
Voltawinget install Volta.VoltaYes (repo-pinned); unmaintained, existing setups only
Direct .msifrom nodejs.org/en/downloadNo

For a development machine, install fnm and enable auto-switching in PowerShell by adding this to your $PROFILE:

powershell
winget install Schniz.fnm
fnm env --use-on-cd | Out-String | Invoke-Expression
fnm install --lts
fnm use lts-latest

For a build server or a quick one-off, winget install OpenJS.NodeJS.LTS is the least-friction path. The .msi installer also offers a "Tools for Native Modules" checkbox that installs the Python and Visual Studio C++ workloads needed to compile native addons (bcrypt, sharp, and friends); tick it if your projects use any.

A version manager installs Node under your home directory, lets you hold several majors side by side, switches between them per project, and means you never need sudo for a global npm package. This is how I set up every dev machine.

fnm (Fast Node Manager, a Rust rewrite of nvm; cross-platform and fast):

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

# add the shell hook (zsh shown; use ~/.bashrc for bash)
echo 'eval "$(fnm env --use-on-cd)"' >> ~/.zshrc
source ~/.zshrc

fnm install --lts          # install latest LTS
fnm use lts-latest         # activate it
fnm default lts-latest     # default for new shells

nvm (the original; Bash script, Linux and macOS only):

bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.41.0/install.sh | bash
source ~/.bashrc           # or ~/.zshrc on macOS

nvm install --lts          # install latest LTS
nvm use --lts              # activate for this shell
nvm alias default --lts    # default for new shells

Volta (transparent, repo-pinned versions; unmaintained, so only for a repo that already uses it):

bash
# Linux / macOS
curl https://get.volta.sh | bash

volta install node@lts     # globally available
# inside a project:
volta pin node@22          # writes a "volta" key into package.json

Volta's own README says "Volta is unmaintained" and recommends moving to mise. Existing installs keep working, but for a new machine pick fnm or mise; the mise equivalent of the pin is mise use node@26, which writes the version to mise.toml.

With any of these, pinning a version per project (.nvmrc, .node-version, or the volta key in package.json) keeps every developer and CI on the same major; pinning a Node version with .nvmrc walks through the file each manager reads and how to wire it into CI. For a head-to-head on which manager to choose, see nvm vs fnm vs Volta.

Install via the official nodejs.org installer

For machines where a version manager is not an option (corporate-managed laptops, kiosks, single-purpose servers), the official installer is the right answer:

  1. Go to nodejs.org/en/download
  2. Choose LTS unless you specifically need Current
  3. Pick your OS and architecture (Windows .msi, macOS .pkg Universal)
  4. Run it; it installs Node and the bundled npm, and adds them to PATH
  5. Open a new terminal (the old one has a stale PATH) and verify
bash
node --version
npm --version

Linux has no installer on nodejs.org. The Linux download is a prebuilt binary archive (node-v26.13.1-linux-x64.tar.xz, or -arm64), which you cannot "run": you extract it and put its bin directory on PATH yourself.

bash
sudo mkdir -p /usr/local/lib/nodejs
sudo tar -xJf node-v26.13.1-linux-x64.tar.xz -C /usr/local/lib/nodejs
echo 'export PATH=/usr/local/lib/nodejs/node-v26.13.1-linux-x64/bin:$PATH' >> ~/.profile

Log in again (or source ~/.profile) and run the same two version checks. Nothing updates that directory for you, which is why on Linux I reach for NodeSource or a version manager first and keep the tarball for machines with no package access.

This method does not give you side-by-side versions: to switch majors later you would reinstall, or install a version manager and let it take over. The macOS .pkg is a Universal binary (native on both Apple Silicon and Intel); the Windows .msi includes the optional native-module build-tools step.

Install in Docker

Inside a container you do not install Node at all, you base the image on an official node: image and pin the version in the FROM line:

dockerfile
# Pin to an LTS major. Recommended for production.
FROM node:26-alpine

# Pin to an exact patch for fully reproducible builds.
FROM node:26.13.1-alpine

# Tracks whatever the current LTS is (convenient, less reproducible).
FROM node:lts-alpine

Use -alpine for the smallest image (musl libc; Docker Hub lists node:26-alpine at about 63 MB compressed for linux/amd64) or -slim (Debian, glibc, about 86 MB) when a dependency needs glibc compatibility. Always pin to a major or major.minor in production, never node:latest: it is a moving tag that changes major whenever the newest release line changes. On 24 November 2026 it points at the same image as node:26. If the FROM line is the only Dockerfile instruction you are sure of, how to write a Dockerfile covers the rest from the ground up; for the full multi-stage Node build, see how to Dockerize a Node.js app.

Verify the install

Whatever method you used, confirm it landed:

bash
node --version     # e.g. v22.11.0
npm --version      # e.g. 10.9.0
which node         # where node is installed (on Windows: where node)

A successful install prints a Node version on the first line and an npm version on the second. which node (or where node) tells you which install is on PATH, which is the diagnostic that resolves nearly every "but I installed it" puzzle: a version manager will print a path under ~/.fnm, ~/.nvm, or ~/.volta; the official installer prints /usr/local/bin/node (macOS) or a Program Files path (Windows), and the Linux binary archive prints wherever you extracted it (/usr/local/lib/nodejs/node-v26.13.1-linux-x64/bin/node with the commands above). For a deeper look at reading and comparing versions, see how to check your Node version. When the time comes to move up a major, updating Node.js walks through every upgrade path and the native-module rebuild step.

A quick smoke test that Node actually runs:

bash
node -e "console.log('node ' + process.version + ' works')"
# node v22.11.0 works

Troubleshooting a fresh install

node: command not found right after installing. The shell has a stale PATH. Open a brand-new terminal. If it persists with a version manager, you missed the shell-init line: fnm needs eval "$(fnm env --use-on-cd)" in ~/.zshrc or ~/.bashrc; nvm needs its sourcing snippet (the installer appends it, but only to one rc file).

A very old version came in via apt. You installed the distro nodejs package instead of NodeSource. Remove it (sudo apt-get remove -y nodejs) and reinstall through NodeSource as shown above, or switch to fnm under your user.

EACCES: permission denied installing a global npm package. Your Node lives in a root-owned directory (typical with a system or Homebrew install) and global npm wants to write there. The clean fix is to use a version manager so npm globals live under your home directory; the quick fix is npm config set prefix ~/.npm-global and add ~/.npm-global/bin to PATH. Do not sudo npm install -g, that compounds the problem.

Homebrew installed a newer major than the LTS line you wanted. brew install node tracks the latest stable release, whatever its phase. Install the pinned LTS formula instead: brew install node@24 && brew link --overwrite node@24.

node-gyp errors when a dependency compiles. Native build tools are missing. Linux: sudo apt-get install -y build-essential python3. macOS: xcode-select --install. Windows: re-run the .msi and tick the native-modules option. A related failure shows up after a successful install when you switch Node majors: a prebuilt native addon throws a NODE_MODULE_VERSION mismatch because it was compiled against the old ABI. Fixing a NODE_MODULE_VERSION mismatch covers the rebuild.

Two managers fighting. If node --version and fnm current (or nvm current) disagree, you have more than one Node manager installed. Pick one, uninstall the others, and reload the shell.

FAQ

For a development machine, a version manager is the best way: install fnm with curl -fsSL https://fnm.vercel.app/install | bash, then fnm install --lts. It installs Node under your home directory, holds multiple versions side by side, and never needs sudo for global packages.

For a server or a locked-down laptop where you cannot add tooling, use the official installer from nodejs.org/en/download or, on Linux, NodeSource. See nvm vs fnm vs Volta for the comparison.

Install LTS for anything real. On 24 November 2026 that means Node 26, the Active LTS; Node 24 and Node 22 are still supported as Maintenance LTS, and Node 20, 21, 23, and 25 are end of life. An LTS line gets 30 months of long-term support and is what npm libraries target. Current is for trying new features early.

The old shortcut was "even numbers are LTS, odd numbers last six months". That held through Node 26. Starting with Node 27 the cycle is annual and every major moves to LTS after six months as Current. The live Node Versions card at the top of this page shows the exact numbers from the Node.js release feed.

Use NodeSource, not the default apt package (which is usually a major behind): run curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - then sudo apt-get install -y nodejs. That installs the current LTS plus npm in one step.

If you would rather not pipe a script to root, install fnm under your own user instead, it needs no sudo and gives you version switching.

No. npm ships bundled with Node.js, so every install method here gives you both. After installing, node --version and npm --version should both print a number.

To move npm independently of Node later, run npm install -g npm@latest. For pnpm or Yarn, use Corepack (corepack enable), which is bundled with Node from 16.10 through 24 (it was removed from the Node 25 distribution, so on 25+ install it with npm install -g corepack).

Do not run an installer in CI. On GitHub Actions, use the official actions/setup-node step and pin the version: set node-version: 22, or point it at your repo's pin with node-version-file: .nvmrc so CI and your laptop stay on the same major.

The full workflow, including dependency caching and the matrix-build pattern, is in setting up Node.js in GitHub Actions with setup-node.

Use a version manager. fnm, nvm, and Volta all install Node under your home directory, so none of them need sudo or administrator rights, and global npm packages land in a user-owned path too. On Linux or macOS: curl -fsSL https://fnm.vercel.app/install | bash then fnm install --lts.

The official .pkg / .msi installers and the NodeSource apt/dnf route all require admin rights, so they are the wrong choice on a locked-down account.

Open a fresh terminal and run node --version and npm --version. Both should print a version. Run which node (or where node on Windows) to confirm which install is on your PATH.

For a runtime smoke test: node -e "console.log(process.version)". More detail on reading versions is in how to check your Node version.

See also

Sources

Authoritative references this article was fact-checked against.

TagsNode.jsJavaScriptnvmfnmVoltaInstallationCLIDockerDevOps

Found this useful? Pass it on.

Copied

Ishan Karunaratne

Systems and Network Architect · Chief Technology Officer

Systems and network architect and Chief Technology Officer with more than two decades designing, building, and running production software, cloud and network architecture, Linux systems, and the bare metal underneath them, and lately working AI into the stack. A US Army veteran who served in Operation Iraqi Freedom. What I write here is drawn from the full arc of that work, across architecture, engineering, and operations, not any single job.

Keep reading

Related posts

Install Docker on Ubuntu (official apt repo), macOS and Windows (Docker Desktop, WSL2), run docker without sudo, and fix 'Cannot connect to the Docker daemon'.

How to Install Docker on Ubuntu, macOS, and Windows (2026)

Install Docker the right way for your OS: the official apt repo on Ubuntu (not the distro's docker.io), Docker Desktop on macOS and Windows, run docker without sudo, fix 'Cannot connect to the Docker daemon', and use your new install to run tools without installing them.

How to uninstall Node.js completely on Linux, macOS, and Windows, including removing leftover npm, npx, and global package directories

How to Uninstall Node.js (Every Install Method)

How to uninstall Node.js cleanly on Linux, macOS, and Windows: version managers (nvm, fnm, Volta, n), the official installer, apt/dnf/brew/winget/choco, Docker, plus verification and optional npm-cache or PATH cleanup.

Toggle macOS dark mode from the terminal with one osascript line, set the volume, turn Bluetooth on or off, take a camera photo and read your calendar.

How to Toggle Dark Mode From the macOS Command Line

Toggle macOS dark mode from the terminal with one osascript line: instant, no restart. Force it on or off, read the current state, and skip the dead _HIEnableThemeSwitchHotKey trick. Plus the other Mac settings from the command line: system volume (osascript), Bluetooth (blueutil), a photo with the Mac camera (imagesnap) and your calendar (cal, icalBuddy).