How To Install NodeJS on Your System?
To run JavaScript outside a browser or use frameworks like React or Express, you need Node.js. Let's see how to install Node.js on Windows, Linux, and Mac systems, ensuring you’re ready for JavaScript development.
Installing Node.js on Windows
In this section, we'll discuss the three different methods that can used to download and install Node.js for Windows users.
1. Download and Install Node.js from the Official Website
Step 1: Download the Node.js Installer
Visit the official Node.js download page and choose your suitable download either long-term support (LST) version 22.12.0 or the current version v23.3.0

Step 2: Run the Node Installer
Open the .msi
installer once downloaded.

During installation, make sure to add Node.js to your PATH to ensure that both Node.js and npm are accessible globally in the command line.
Step 3: Verify Installation
Open Command Prompt and run the following to check if Node.js and npm are correctly installed:
node -v
npm -v
This will display the installed versions of Node.js and npm.
2. Install Using Windows Package Manager (Winget)
Step 1: Open PowerShell as Administrator
Right-click the Start menu and select Windows PowerShell (Admin).

Step 2: Install Node.js via Winget
Execute the following command to install Node.js:
winget install OpenJS.Node.js
Also, check the installed versions of Node.js and npm once the installation is complete using the following command:
node -v
npm -v
3. Install using WSL(2) *recommended
Step 1: Enable WSL (Windows Subsystem for Linux)
Open PowerShell as Administrator and run the following command:
wsl --install

Choose your preferred Linux distribution (Ubuntu is widely used).
Step 2: Install Node.js on WSL
Once your Linux subsystem is set up, you can install Node.js via your chosen Linux distribution:

sudo apt update
sudo apt install Node.js npm
Later, you can run the following commands to verify the installation:
node -v
npm -v
Install Node.js on macOS
You may download and install node on macOS using these 3 defined methods below, let's check them out along with their steps:
1. Download and Install Node.js via Homebrew
Step 1: Install Homebrew
Open Terminal and run the following command to install homebrew version 23.3.0 (if you haven’t already):

/bin/bash -c "$(curl -fsSL https://raw.usercontent.com/Homebrew/install/HEAD/install.sh)"
Step 2: Install Node.js
After Homebrew is installed, run the following command to install Node.js:

brew install node
Once the installation is complete, you may check if Node.js and npm are successfully installed by running:
node -v
npm -v

2. Install Node.js from the Official Website
Node js offer users to get the download done from it's official website as well and this might be the simplest method to download and install Node in your system.
Step 1: Download the macOS Installer v23.3.0
Visit the Node.js official site and download the macOS installer for either the LTS v22.12.0 or Current version v23.3.0

Step 2: Run the Installer
Open the downloaded .pkg
file and follow the instructions to complete the installation.

Step 3: Verify Installation
Once installed, open Terminal and check the Node.js and npm versions:
node -v
npm -v

3. Install Node.js Using NVM
Step 1: Install NVM
Run the following command to install NVM (a version manager for Node.js):

curl -o- https://raw.usercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
Step 2: Install Node.js Using NVM v22.12.0 (LTS)
After NVM is installed, you can install any version of Node.js:
nvm install node # Installs the latest version of Node.js
Also, you can verify Installation using the following command
node -v
npm -v

Install Node.js on Linux
Now, we'll be discussing the 3 methods to Install Node on your Linux system.
1. Install Node.js Using APT (For Ubuntu/Debian-based Distributions)
Step 1: Update the Package List v22.12.0 (LTS)
Go to Terminal and execute the following command:

sudo apt update
Step 2: Install Node.js on your System
Now, run the following command to Install Node.js and npm:

sudo apt install Node.js npm
Step 3: Verify Installation
Once the installation is complete, you may check the installed versions using the following command:
node -v
npm -v
2. Install Node.js Using DNF (For Fedora)
Step 1: Install Node.js for Fedora 41
Open Terminal and run

sudo dnf install Node.js
Step 2: Verify Installation
After installation, verify Node.js and npm by using the following command:
node -v
npm -v

3. Install Node using NVM
Step 1: Install NVM v22.12.0 (LTS)
Run this command to install NVM, which helps manage different versions of Node.js:

curl -o- https://raw.usercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
Step 2: Install Node using NVM
After installing NVM, run
nvm install node # Installs the latest version

Step 3: Verify Installation
Run the following command to verify node installation:
node -v
npm -v

Troubleshooting Common Issues
Issue 1: Node.js Not Added to PATH
If node
or npm
commands are not recognized, ensure Node.js is added to your system’s PATH. This is particularly common with manual installation methods.
Issue 2: Permission Errors
When installing Node.js globally, you may face permission issues. You can resolve this by running the commands with sudo
(on Linux/macOS) or by using an administrator account (on Windows). Alternatively, use NVM to avoid these problems.
Issue 3: Outdated Versions
If you're using an outdated version of Node.js or npm, you can upgrade to the latest version by running:
npm install -g npm
Key Takeaways
- Windows users can use the official installer or winget for a streamlined installation process.
- macOS developers can easily install Node.js using Homebrew or the official installer.
- Linux users have the flexibility of using APT, DNF, or NVM to install Node.js.
- NVM offers a powerful way to manage multiple versions of Node.js, making it ideal for development environments that require flexibility.