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)