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)