Install Node.js
Before you can run any server code, you need Node.js on your computer. Installing it also gives you npm, the package manager you will use to add libraries such as Express.
In this lesson you will choose the right version, install it with the official installer or with a version manager, check that everything works, and learn how to fix the most common install problems on Windows, macOS and Linux.
Which version should you install?
The Node.js website offers several versions. Pick the one marked LTS (Long Term Support). In late 2026 that is Node.js 26 "Lithium", which became LTS on 28 October 2026 and will receive fixes until April 2029. It comes with npm 11.
| Version | Status in late 2026 | Use it for |
|---|---|---|
| Node.js 26 | Active LTS | New projects and this course |
| Node.js 24 | Previous LTS (still supported) | Existing projects that have not upgraded yet |
| Node.js 22 | Older LTS, nearing its end | Only old projects |
| Node.js 27 | Pre-release (alpha) | Testing future features, never production |
| Node.js 20 and older | End of life, no security fixes | Nothing; upgrade them |
Almost every example in this course also works on Node.js 22 and 24. When a feature needs a newer version, the lesson says so.
Option 1: the official installer
This is the easiest choice if you only need one version of Node.js.
- Open the official download page at
https://nodejs.org/en/download. - Choose the LTS version and your system. Windows users get a
.msifile and macOS users get a.pkgfile. - Run the installer and accept the default options. It installs
node,npmandnpxand adds them to yourPATH, the list of folders your terminal searches for commands. - Close and reopen your terminal so it sees the new
PATH.
On Linux, the version in your distribution's default package list is often old. Use a version manager (below) instead.
Option 2: a version manager (recommended for developers)
Real projects do not all use the same Node.js version. Your college project may use Node.js 26 while an office project still runs on Node.js 24. A version manager installs many versions side by side and switches between them with one command. It also installs everything inside your user folder, so you never need administrator rights or sudo for global packages.
There are three popular choices:
- nvm for macOS, Linux and WSL (Windows Subsystem for Linux). It is a shell script.
- fnm ("Fast Node Manager") for Windows, macOS and Linux. It is a single fast program.
- nvm-windows, a separate project with a similar name for native Windows.
nvm on macOS, Linux or WSL
Run the install script from the nvm project, then open a new terminal:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.8/install.sh | bash
# open a new terminal, then:
nvm install --lts # install the newest LTS version
nvm install 24 # also install Node.js 24
nvm use 26 # switch this terminal to Node.js 26
nvm alias default 26 # use 26 in every new terminal
nvm ls # list installed versionsfnm on Windows
On Windows 10 or 11, install fnm with winget, then add one line to your PowerShell profile so fnm runs in every new window:
winget install Schniz.fnm
# create your profile file if it does not exist, then open it
if (-not (Test-Path $profile)) { New-Item $profile -Force }
Invoke-Item $profileAdd this line at the end of the profile file and save it:
fnm env --use-on-cd --shell powershell | Out-String | Invoke-ExpressionOpen a new PowerShell window and install Node.js:
fnm install --lts
fnm install 24
fnm use 26
fnm default 26
fnm listThe --use-on-cd option makes fnm switch versions automatically when you cd into a folder that has a version file (shown below). On macOS and Linux you can install fnm with brew install fnm and add eval "$(fnm env --use-on-cd --shell bash)" to your .bashrc.
Check your installation
Open a new terminal and ask each tool for its version:
node -v
npm -v
npx -vv26.13.0 11.20.0 11.20.0
Your exact numbers may be newer. If you see command not found or 'node' is not recognized as an internal or external command, the terminal cannot find Node.js on its PATH. Close every terminal (including the one inside VS Code) and open a new one. If it still fails, run the installer again, or check that the version manager line is in your shell profile.
To see where the command lives, use where node in Windows PowerShell or Command Prompt, and which node on macOS or Linux. This quickly shows if an old copy is being picked up first.
Pin a version for each project
When several people work on one project, everyone should use the same Node.js version. Save it in a small text file in the project folder:
node -v > .nvmrc
cat .nvmrcv26.13.0
Now anyone with nvm can run nvm use (with no version) inside the folder, and nvm reads .nvmrc. fnm reads both .nvmrc and .node-version, and with --use-on-cd it switches automatically. Later, in npm & package.json, you will also see the engines field, which records the supported versions inside package.json.
Set up your editor
Any editor works, but Visual Studio Code is free, runs on every system and understands JavaScript and Node.js well. Open your project folder with File > Open Folder, then open a terminal inside the editor with Terminal > New Terminal. You will type every node and npm command from this course in that terminal.
Create a folder for this course, for example node-course, and keep each lesson's files in it.
Common mistakes
- Downloading the alpha or an odd-numbered version. Choose the LTS release for learning and for production.
- Keeping an old terminal open. A terminal that was open before the install does not see the new
PATH. Open a fresh one. - Using
sudo npm install -gon Linux or macOS. It creates root-owned files and permission errors later. Use nvm or fnm instead, which install into your home folder. - Installing from an old Linux package list. You may get a version that reached end of life years ago. Check with
node -v.
Key points
- Install the LTS version: Node.js 26 "Lithium" in late 2026, with Node.js 24 as the previous LTS.
- The official installer (
.msior.pkg) is simplest when you need only one version. - Version managers (nvm, fnm, nvm-windows) let you install and switch between versions without admin rights.
- Check the install with
node -vandnpm -vin a new terminal. - Save the project's version in
.nvmrcor.node-versionso the whole team uses the same one. - Corepack is no longer bundled from Node.js 25; npm is always included.
Exercise
Install Node.js 26 with either the official installer or a version manager. Then, in a new folder called node-course, create an .nvmrc file that contains your Node.js version, and write a file check.js that prints the Node.js version and the name of your operating system using process.version and process.platform. Run it with node check.js.
Show solution
mkdir node-course
cd node-course
node -v > .nvmrc// check.js
console.log(`Node.js ${process.version} on ${process.platform}`);Node.js v26.13.0 on win32
process.platform prints win32 on Windows (even on 64-bit systems), darwin on macOS and linux on Linux.
Quick Quiz
1. Which Node.js version should a beginner install in late 2026?
LTS versions are stable and get security fixes; Node.js 20 has reached end of life and 27 is a pre-release.
2. What is the main benefit of a version manager such as nvm or fnm?
A version manager lets each project use the version it needs, without administrator rights.
3. node -v says "not recognized" right after installing. What should you try first?
Terminals read PATH when they start, so one opened before the install cannot find node.
4. Which file lets nvm pick the right Node.js version for a project when you run nvm use?
nvm reads the version from .nvmrc; fnm reads .nvmrc and .node-version.
Learn Node.js with a mentor
Free lessons get you started. Our Full Stack Web Development training adds real projects and code reviews from working developers.
- Project-based learning
- Mentor code reviews
- Free counselling call
