NodeJSInstalling Node.js

Installing Node.js

Before you can run a single line of server-side JavaScript you need Node.js on your machine. Installing Node also installs npm (the package manager) and npx (the package runner) automatically — they ship in the same bundle. This page surveys your options and the trade-offs; the OS-specific pages then go step by step.

What actually gets installed

A Node install is not one program but a small toolkit. Knowing what each piece is prevents confusion later:

Binary

What it is

node

The runtime itself — runs your JavaScript files

npm

The package manager — installs dependencies, runs scripts

npx

Runs a package bin without a global install (npx create-next-app)

corepack

Shim that manages yarn/pnpm versions (opt-in, ships with Node)

Which version should I install?

Pick the latest LTS (Long-Term Support) release — the even-numbered lines (18, 20, 22…). LTS versions are stable and supported for ~30 months, which is what you want for real projects. Use Current only to experiment with the newest features on a throwaway branch. Full breakdown in LTS vs Current Releases.

Three ways to install

Method

Best for

Trade-off

Official installer

Beginners, a single fixed version

Switching versions later is manual

Version manager (nvm/fnm/volta)

Anyone with more than one project

One extra setup step — worth it

OS package manager (brew/winget/apt)

Matching your system tooling

Distro versions often lag behind

Recommendation
For anything beyond a one-off, install via a **version manager** like `nvm`. Different projects often need different Node versions, and a manager makes switching painless — with no `sudo` and no system-file conflicts. See [Version Management with nvm](/nodejs/nvm).
Avoid sudo-installing global packages
If `npm install -g` ever demands `sudo`, that is a signal your Node lives in a system directory you should not be writing to. A version manager puts Node in your home directory, so global installs need no elevated permissions — and you avoid the classic `EACCES` permission errors.
Verify your installation

After installing, open a fresh terminal (so it picks up the new PATH) and check the versions:

Bash
node --version   # or: node -v
npm --version    # or: npm -v
v20.11.0
10.2.4
Troubleshooting "command not found"

Symptom

Likely cause & fix

node: command not found

Terminal has stale PATH — close and reopen it (or restart)

Old version after upgrade

A second Node is earlier on PATH — check which -a node

Works in one terminal, not another

Shell profile (.zshrc vs .bashrc) wasn't sourced

EACCES on global install

Node is in a root-owned dir — switch to a version manager

Bash
which node     # macOS/Linux: where is the node binary?
where node     # Windows: same question
Run your first command

The -e flag ("evaluate") runs a string of code directly — a quick way to confirm the runtime works without creating a file:

Bash
node -e "console.log('Node is working!')"
Node is working!
Pick your platform
Next
Once installed, learn to manage versions with [nvm](/nodejs/nvm), then explore the interactive [Node.js REPL](/nodejs/node-repl).