DEV Community

Hiro Ventolero
Hiro Ventolero

Posted on

🚀 How to Install Node.js (or a Specific Version) on Windows, macOS, and Linux

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
Enter fullscreen mode Exit fullscreen mode

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

  1. Go to https://nodejs.org
  2. Download the LTS (Long-Term Support) version.
  3. Run the installer:
  • Accept the license
  • Choose the destination folder
  • ✅ Check “Add to PATH”
    1. Verify installation:
   node -v
   npm -v
Enter fullscreen mode Exit fullscreen mode

🍎 For macOS Users

You can install Node.js either with Homebrew or the official installer.

Option 1: Install via Homebrew (Recommended)

brew install node
Enter fullscreen mode Exit fullscreen mode

To install a specific version:

brew install node@18
Enter fullscreen mode Exit fullscreen mode

Then link it to make it the default version:

brew link --overwrite node@18
Enter fullscreen mode Exit fullscreen mode

Option 2: Install via Official Installer

  1. Visit https://nodejs.org
  2. Download the macOS Installer (LTS).
  3. Run the setup and finish installation.

Verify:

node -v
npm -v
Enter fullscreen mode Exit fullscreen mode

🐧 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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Verify installation:

node -v
npm -v
Enter fullscreen mode Exit fullscreen mode

⚙️ 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
Enter fullscreen mode Exit fullscreen mode

🎯 Install a Specific Version

nvm install 18
Enter fullscreen mode Exit fullscreen mode

To list all available versions:

nvm ls-remote
Enter fullscreen mode Exit fullscreen mode

Switch between versions anytime:

nvm use 18
Enter fullscreen mode Exit fullscreen mode

Set a default version:

nvm alias default 18
Enter fullscreen mode Exit fullscreen mode

🪟 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
Enter fullscreen mode Exit fullscreen mode

Check version:

node -v
Enter fullscreen mode Exit fullscreen mode

🧰 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
Enter fullscreen mode Exit fullscreen mode

Create a simple index.js:

console.log("Node.js is working!");
Enter fullscreen mode Exit fullscreen mode

Run it:

node index.js
Enter fullscreen mode Exit fullscreen mode

If you see:

Node.js is working!
Enter fullscreen mode Exit fullscreen mode

🎉 You’ve successfully installed Node.js!


⚡ Optional: Update npm to the Latest Version

npm install -g npm@latest
Enter fullscreen mode Exit fullscreen mode

✅ 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)