Node.js has become one of the most popular JavaScript runtime environments, allowing developers to build server-side applications with ease. Along with Node.js, npm (Node Package Manager) is essential for managing packages and dependencies in your projects. Whether you are a beginner or an experienced developer, installing Node.js and npm correctly is the first step to building modern applications.

In this guide, you will learn how to install Node.js and npm on Windows, macOS, and Linux in simple, step-by-step instructions.
Prerequisites
Before installing Node.js and npm, ensure your system meets the following requirements:
- Basic system requirements: Modern processor and at least 1 GB RAM.
- Administrative access: You should have permissions to install software on your system.
- Internet connection: Required to download installers and packages.
Having these ready will make the installation smooth and error-free.
How to Install Node.js and npm on Windows
Installing Node.js on Windows is straightforward. The Node.js installer also includes npm, so you don’t need to install it separately.
Step 1: Download the Installer
- Go to the official Node.js website.
- You will see two versions: LTS (Long Term Support) and Current.
- Click the Windows installer to download the
.msi
file.
Note: The LTS (Long Term Support) version is recommended for most users as it provides stability and regular updates. The Current version includes the latest features but may be less stable, making it better suited for testing and development.
Step 2: Run the Installer
- Open the downloaded file.
- Follow the prompts in the setup wizard, and keep the default options checked (including npm).
- Click Install and wait for the process to complete.
Step 3: Verify Installation
- Open Command Prompt.
- Type the following commands:
node -v npm -v
- If both commands return version numbers, Node.js and npm are successfully installed.
How to Install Node.js and npm on macOS
On macOS, you have two main methods to install Node.js and npm: using the official installer or Homebrew.
Method 1: Using Official Installer
- Visit the Node.js website.
- Download the macOS
.pkg
installer. - Open the installer and follow the prompts.
- Verify installation in Terminal:
node -v npm -v
Method 2: Using Homebrew
Homebrew is a package manager for macOS and makes installation easy.
- Install Homebrew if you don’t have it:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Install Node.js and npm:
brew install node
- Verify installation:
node -v
npm -v
How to Install Node.js and npm on Linux
Linux users have several options to install Node.js and npm, depending on the distribution.
Method 1: Using Package Manager
For Debian/Ubuntu:
sudo apt update
sudo apt install nodejs npm -y
For Fedora:
sudo dnf install nodejs npm -y
For CentOS:
sudo yum install nodejs npm -y
Verify installation:
node -v
npm -v
Method 2: Using Node Version Manager (nvm)
nvm
allows you to manage multiple Node.js versions easily.
- Install nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
- Load nvm:
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
- Install Node.js and npm using nvm:
nvm install --lts
nvm use --lts
- Verify installation:
node -v
npm -v
Updating Node.js and npm
Keeping Node.js and npm updated ensures access to the latest features and security fixes.
- Windows & macOS: Download the latest installer from the Node.js website and run it.
- Linux (with package manager):
sudo apt update && sudo apt upgrade nodejs npm
- Linux (with nvm):
nvm install --lts --reinstall-packages-from=current
nvm use --lts
Conclusion
Installing Node.js and npm is the first essential step for any JavaScript developer. By following this guide, you can now install Node.js and npm on Windows, macOS, and Linux without any issues. After installation, test your setup by running a simple Node.js script or installing a package using npm. With Node.js and npm ready, you’re all set to start building fast, scalable applications.