How to Install Node.js on Windows, macOS, and Linux

Learn how to install Node.js on Windows, macOS, and Linux with step-by-step instructions. Set up Node.js and npm easily for JavaScript development.

How to Install Node.js on Windows, macOS, and Linux
Node.js is a popular JavaScript runtime that allows developers to build scalable web applications, backend services, and more. In this guide, we will walk you through the steps to install Node.js on Windows, macOS, and Linux.
1. Check if Node.js is Already Installed
Before installing, check if you already have Node.js by running the following command in your terminal or command prompt:
node -v
If Node.js is installed, this command will return the installed version number. If not, proceed with the installation.
2. Installing Node.js on Windows
Using the Official Installer
Visit the official Node.js website: https://nodejs.org
Download the LTS (Long-Term Support) version for stability.
Open the downloaded
.msi
installer and follow the setup instructions.Ensure you check the box for adding Node.js to
PATH
during installation.Once installed, verify by running:
node -v
npm -v
3. Installing Node.js on macOS
Using Homebrew (Recommended)
Homebrew is a package manager for macOS that makes installations easier.
Open Terminal and install Homebrew (if not installed):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install Node.js:
brew install node
Verify installation:
node -v
npm -v
4. Installing Node.js on Linux
Using Node Version Manager (NVM) - Recommended
NVM allows you to install and manage multiple Node.js versions easily.
Install NVM:
curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
Reload shell:
source ~/.bashrc # or source ~/.zshrc if using zsh
Install the latest LTS version of Node.js:
nvm install --lts
Verify installation:
node -v
npm -v
Using Package Managers
For Ubuntu/Debian:
sudo apt update && sudo apt install nodejs npm -y
For Fedora:
sudo dnf install nodejs
5. Verifying Node.js and npm Installation
Run the following commands to ensure Node.js and npm (Node Package Manager) are installed correctly:
node -v # Check Node.js version
npm -v # Check npm version
6. Managing Node.js Versions
If you need to switch between multiple Node.js versions, use NVM:
nvm list # List installed versions
nvm use <version> # Switch to a specific version
Conclusion
Congratulations! You have successfully installed Node.js on your system. You can now start building JavaScript applications and using npm to manage dependencies.
For more tutorials, visit CoderCrafter.