If you’re diving into backend development or exploring frameworks like Express, Next.js, or NestJS, installing Node.js is your first step.
This guide covers how to install Node.js (and a specific version, if needed) on Windows, macOS, and Linux — including npm, nvm, and version management tips.
🧠 What is Node.js?
Node.js is an open-source, cross-platform JavaScript runtime built on Chrome’s V8 engine.
It lets you run JavaScript outside the browser — perfect for creating servers, APIs, CLI tools, and full-stack applications.
🧩 Step 1: Check if Node.js is Already Installed
Open your terminal (or PowerShell on Windows) and run:
node -v
npm -v
If both return version numbers, you already have Node.js installed.
If not, let’s install it!
💻 Step 2: Install Node.js
🪟 For Windows Users
- Go to https://nodejs.org
- Download the LTS (Long-Term Support) version.
- Run the installer:
- Accept the license
- Choose the destination folder
- ✅ Check “Add to PATH”
- Verify installation:
node -v
npm -v
🍎 For macOS Users
You can install Node.js either with Homebrew or the official installer.
Option 1: Install via Homebrew (Recommended)
brew install node
To install a specific version:
brew install node@18
Then link it to make it the default version:
brew link --overwrite node@18
Option 2: Install via Official Installer
- Visit https://nodejs.org
- Download the macOS Installer (LTS).
- Run the setup and finish installation.
Verify:
node -v
npm -v
🐧 For Linux Users (Ubuntu/Debian)
Install Latest LTS
sudo apt update
sudo apt install -y curl
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt install -y nodejs
Install a Specific Version (e.g., Node 18)
Replace 18.x
with your desired version:
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install -y nodejs
Verify installation:
node -v
npm -v
⚙️ Step 3: Use nvm (Node Version Manager) for Flexibility
If you manage multiple Node projects, nvm (Node Version Manager) is the best way to switch between Node versions easily.
🧰 Install nvm (macOS/Linux)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
source ~/.bashrc
🎯 Install a Specific Version
nvm install 18
To list all available versions:
nvm ls-remote
Switch between versions anytime:
nvm use 18
Set a default version:
nvm alias default 18
🪟 For Windows Users
Install nvm for Windows from:
👉 https://github.com/coreybutler/nvm-windows
Once installed:
nvm install 18.17.1
nvm use 18.17.1
Check version:
node -v
🧰 Step 4: Verify Installation and Run a Test App
Create a folder and initialize a project:
mkdir my-node-app
cd my-node-app
npm init -y
Create a simple index.js
:
console.log("Node.js is working!");
Run it:
node index.js
If you see:
Node.js is working!
🎉 You’ve successfully installed Node.js!
⚡ Optional: Update npm to the Latest Version
npm install -g npm@latest
✅ Final Thoughts
You now have Node.js installed — and even better, you can manage multiple versions effortlessly with nvm
.
This setup is essential if you:
- Work on multiple Node projects
- Use frameworks requiring specific Node versions
- Contribute to open-source repositories with version requirements
Top comments (0)