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.
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.
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
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
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
For Ubuntu/Debian:
sudo apt update && sudo apt install nodejs npm -y
For Fedora:
sudo dnf install nodejs
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
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
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.