Skip to main content

Installation methods

Node.js can be installed using several methods depending on your operating system and requirements. Choose the method that best fits your needs:

Official installer

Recommended for most users. Download pre-built binaries from nodejs.org.

Version manager

Recommended for developers. Easily switch between Node.js versions.

Package manager

Install via your OS package manager (apt, brew, winget).

Build from source

Advanced users who need custom builds or unsupported platforms.

Windows installation

Method 1: Official installer

1

Download the installer

Visit nodejs.org/download and download the Windows Installer (.msi) for your architecture:
  • 64-bit: Recommended for most modern Windows systems
  • ARM64: For Windows on ARM devices
Download the LTS (Long Term Support) version for production applications.
2

Run the installer

  • Double-click the downloaded .msi file
  • Follow the installation wizard
  • Accept the license agreement
  • Choose the installation directory (default: C:\Program Files\nodejs\)
  • Select components to install (keep defaults)
3

Verify installation

Open Command Prompt or PowerShell and run:
node --version
npm --version
You should see version numbers for both Node.js and npm.

Method 2: Windows Package Manager (winget)

# Install latest LTS version
winget install OpenJS.NodeJS.LTS

# Or install current version
winget install OpenJS.NodeJS

Method 3: Version manager (nvm-windows)

1

Download nvm-windows

2

Install nvm-windows

Run the installer and follow the setup wizard.
3

Install Node.js

# List available versions
nvm list available

# Install latest LTS
nvm install lts

# Install specific version
nvm install 20.11.0

# Use installed version
nvm use 20.11.0

# List installed versions
nvm list
Developer Mode requirementOn Windows, creating symlinks requires Developer Mode to be enabled or running as Administrator. Some tests may fail without proper permissions.

macOS installation

Method 1: Official installer

1

Download the installer

Visit nodejs.org/download and download the macOS Installer (.pkg):
  • x64: For Intel-based Macs
  • ARM64: For Apple Silicon (M1/M2/M3) Macs
2

Run the installer

  • Double-click the .pkg file
  • Follow the installation wizard
  • You may need to enter your password
3

Verify installation

node --version
npm --version

Method 2: Homebrew

# Install Homebrew if you haven't already
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install Node.js LTS
brew install node@20

# Or install current version
brew install node

# Link the installed version
brew link node@20

Method 3: Version manager (nvm)

1

Install nvm

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
Or using wget:
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
2

Load nvm

Add to your shell profile (~/.zshrc, ~/.bashrc, or ~/.bash_profile):
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
Reload your shell:
source ~/.zshrc  # or ~/.bashrc
3

Install Node.js

# Install latest LTS
nvm install --lts

# Install specific version
nvm install 20.11.0

# Use installed version
nvm use 20.11.0

# Set default version
nvm alias default 20.11.0

# List installed versions
nvm ls

Method 4: Version manager (n)

# Install n globally using npm (requires Node.js to be installed first)
npm install -g n

# Or install n without Node.js
curl -L https://bit.ly/n-install | bash

# Install LTS version
n lts

# Install latest version
n latest

# Install specific version
n 20.11.0

# List installed versions
n ls

Linux installation

Method 1: Package manager (Ubuntu/Debian)

1

Update package index

sudo apt update
2

Install Node.js from NodeSource

# Download and run NodeSource setup script for Node.js 20.x
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -

# Install Node.js
sudo apt install -y nodejs
3

Verify installation

node --version
npm --version

Method 2: Package manager (Fedora/RHEL/CentOS)

# Download and run NodeSource setup script
curl -fsSL https://rpm.nodesource.com/setup_20.x | sudo bash -

# Install Node.js
sudo dnf install -y nodejs

# Or for older systems using yum
sudo yum install -y nodejs

Method 3: Package manager (Arch Linux)

sudo pacman -S nodejs npm

Method 4: Version manager (nvm)

1

Install build dependencies

sudo apt install -y curl build-essential libssl-dev
2

Install nvm

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
3

Load nvm and install Node.js

# Reload shell configuration
source ~/.bashrc

# Install latest LTS
nvm install --lts

# Verify installation
node --version
npm --version

Building from source

For advanced users who need custom builds or work on unsupported platforms.

Prerequisites

Before building Node.js from source, ensure you have the required dependencies:
# Install Xcode Command Line Tools
xcode-select --install

# Install required tools
brew install python3 gcc make
System requirements:
  • Python 3.x (for building and testing)
  • GCC >= 12.2 or Clang >= 19.1
  • GNU Make >= 3.81
  • At least 8GB RAM for compilation

Build steps

1

Clone the repository

git clone https://github.com/nodejs/node.git
cd node
2

Checkout desired version

# List available versions
git tag

# Checkout specific version (e.g., v20.11.0)
git checkout v20.11.0

# Or use latest from main branch
git checkout main
3

Configure the build

# Basic configuration
./configure

# Or with custom options
./configure --prefix=/usr/local/node
Run ./configure --help to see all available configuration options.
4

Compile Node.js

# Build with 4 parallel jobs
make -j4
Building Node.js can take 15-30 minutes depending on your system. The -j4 flag runs 4 parallel jobs to speed up compilation.
5

Test the build (optional)

# Run test suite
make test-only

# Or run full test suite (includes linting)
make test
6

Install Node.js

sudo make install

Build configuration options

Common configuration options for custom builds:
# Install to custom directory
./configure --prefix=/opt/nodejs

# Build with debug symbols
./configure --debug

# Build without internationalization support
./configure --without-intl

# Build with small ICU (English only)
./configure --with-intl=small-icu

# Build without OpenSSL assembly optimization
./configure --openssl-no-asm

# Enable Address Sanitizer for debugging
./configure --enable-asan

Version managers comparison

Choosing the right version manager:
Featurenvmnnvm-windows
PlatformmacOS, LinuxmacOS, LinuxWindows
InstallationShell scriptnpm or scriptInstaller
SpeedFastVery fastFast
Shell integrationExcellentGoodGood
Active developmentYesYesYes
Use caseMost flexibleSimplestWindows only
Recommended choices:
  • Windows: nvm-windows
  • macOS/Linux: nvm (most popular) or n (simpler)

Verifying your installation

After installation, verify everything is working correctly:

Check versions

# Node.js version
node --version
# Output: v20.11.0

# npm version
npm --version
# Output: 10.2.4

# Check installation paths
which node
which npm

Run a test script

node -e "console.log('Node.js is working!')"
# Output: Node.js is working!

Check available binaries

Node.js installation includes several binaries:
# Interactive REPL
node

# Package manager
npm

# Alternative package manager (included with Node.js)
npx

Updating Node.js

Using version managers

# Install latest LTS
nvm install --lts

# Switch to new version
nvm use --lts

# Set as default
nvm alias default lts/*

Using package managers

winget upgrade OpenJS.NodeJS.LTS

Uninstalling Node.js

Windows

# Using winget
winget uninstall OpenJS.NodeJS

# Or use Windows Settings
# Settings > Apps > Installed apps > Node.js > Uninstall

macOS

# If installed via Homebrew
brew uninstall node

# If installed via official installer
sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/{npm*,node*,man1/node*}

Linux

# Ubuntu/Debian
sudo apt remove nodejs npm

# Fedora/RHEL
sudo dnf remove nodejs npm

Troubleshooting

Permission errors

If you encounter permission errors when installing global packages:
# Don't use sudo with npm!
# Instead, configure npm to use a different directory
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'

# Add to your shell profile
export PATH=~/.npm-global/bin:$PATH

Path issues

If node or npm commands are not found:
# macOS/Linux: Add to ~/.zshrc or ~/.bashrc
export PATH="/usr/local/bin:$PATH"

# Windows: Add to PATH environment variable
# C:\Program Files\nodejs\

Multiple Node.js installations

If you have conflicts from multiple installations:
# Check all node installations
which -a node

# Check current node path
which node

# Use version manager to manage installations

Next steps

Now that you have Node.js installed, you’re ready to start building:

Quickstart

Create your first Node.js application

Introduction

Learn about Node.js architecture and features

API reference

Explore Node.js built-in modules

Best practices

Learn Node.js development best practices

Additional resources