Skip to content
Node.js nd getting-started 4 min read

Installing Node.js

Getting Node.js onto your machine is the first concrete step toward running JavaScript outside the browser. Node ships as a single runtime that bundles the V8 engine, the standard library, and npm — the package manager — so one install gives you everything you need to run scripts, manage dependencies, and build servers. This page walks through every supported path: the official graphical installer, Homebrew on macOS, apt on Debian/Ubuntu, and winget on Windows. It also explains the LTS versus Current release lines so you pick the right version for production work.

Choosing a release line: LTS vs Current

Node.js publishes two parallel release lines. LTS (Long-Term Support) releases carry even major version numbers (20, 22) and receive bug and security fixes for roughly 30 months, making them the safe default for production and for most learning. Current releases carry the latest features but a shorter support window and more churn.

Release lineExample versionBest forSupport window
LTS (“Active”/“Maintenance”)22.x, 20.xProduction apps, teams, tutorials~30 months
Current24.xTrying new language/runtime features early~6 months

Unless you have a specific reason to be on Current, install the latest LTS (Node 22 at the time of writing). Hosting platforms, CI images, and most libraries are validated against LTS first.

Official installer (all platforms)

The simplest cross-platform option is the prebuilt installer from nodejs.org. Download the LTS package for your OS — a .msi on Windows, a .pkg on macOS, or a tarball on Linux — and run it. The installer adds node and npm to your PATH automatically, so they work in any new terminal session after installation completes.

This route is ideal for a first install or for users who prefer a guided, click-through experience. The trade-off is that upgrading later means downloading a fresh installer, whereas package managers handle upgrades in one command.

macOS with Homebrew

If you already use Homebrew, installing Node is a one-liner. Homebrew tracks the Node formula and lets you upgrade alongside your other CLI tools.

# Install the latest stable Node (includes npm)
brew install node

# Or pin to an LTS major version
brew install node@22

# Later, upgrade in place
brew upgrade node

Homebrew installs into its own prefix and links node/npm onto your PATH. If you installed a versioned formula such as node@22, follow the brew info node@22 instructions to link it.

Linux with apt (Debian / Ubuntu)

The version of Node in the default Ubuntu and Debian repositories is often several releases behind. For an up-to-date and well-maintained build, use the NodeSource distribution, which publishes an apt repository pinned to a specific major line.

# Add the NodeSource repo for the Node 22 LTS line
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -

# Install Node + npm from that repo
sudo apt-get install -y nodejs

After this, apt-get upgrade keeps Node patched within the 22.x line. To jump to a newer major later, re-run the setup_NN.x script for that version, then reinstall.

Avoid mixing sudo apt install nodejs from the default repo with a NodeSource or nvm install. Two competing copies on the PATH lead to confusing “wrong version” bugs. Pick one source per machine.

Windows with winget

On Windows 10/11, the built-in winget package manager installs and updates Node without a manual download. Open PowerShell or Terminal and run one of:

# Latest LTS
winget install OpenJS.NodeJS.LTS

# Latest Current
winget install OpenJS.NodeJS

Open a new terminal afterward so the updated PATH takes effect. To update later, run winget upgrade OpenJS.NodeJS.LTS.

Verifying the installation

Whichever method you used, confirm the runtime and npm are on your PATH by printing their versions. Open a fresh terminal so any PATH changes are picked up.

node -v
npm -v

Output:

v22.16.0
10.9.2

A quick way to confirm the runtime actually executes JavaScript is a one-line program. Node 22 supports ES modules natively, so this console.log runs the same whether saved as .mjs or run inline:

node --eval "console.log(`Hello from Node ${process.version}`)"

Output:

Hello from Node v22.16.0

If node is “not recognized” or “command not found”, the install did not update your shell’s PATH — close and reopen the terminal, or on Windows sign out and back in.

Best Practices

  • Default to the latest LTS release for anything you intend to ship or share.
  • Prefer a package manager (brew, apt/NodeSource, winget) over the GUI installer so upgrades are a single command.
  • Install Node from exactly one source per machine to avoid PATH conflicts and version confusion.
  • Always open a fresh terminal after installing or upgrading so the new PATH is loaded.
  • Verify with node -v and npm -v immediately, and check both against the version you expected.
  • If you juggle multiple Node versions across projects, consider a version manager like nvm, fnm, or Volta instead of system-wide installs.
Last updated June 14, 2026
Was this helpful?