Learning how to install Node.js on macOS is one of the most essential and frequently performed tasks for any JavaScript developer, full-stack engineer, web designer, or aspiring coder in 2025–2026 — Node.js powers modern web development (React, Next.js, Vue, Express, NestJS), serverless functions, desktop apps (Electron), mobile backends, automation scripts, CLI tools, and almost every serious JavaScript ecosystem project. Installing Node.js correctly on macOS gives you access to npm (the world’s largest package registry), Yarn, pnpm, and hundreds of thousands of libraries instantly.
In this up-to-date install Node.js on macOS guide, you’ll learn two proven methods:
- Homebrew — fastest, simplest, system-wide install (recommended for most users)
- nvm (Node Version Manager) — best for switching versions, multiple projects, testing LTS vs current
You’ll also create your first Node.js program, verify npm, update Node.js, and troubleshoot common macOS issues.
Prerequisites
- macOS Ventura (13), Sonoma (14), Sequoia (15) or later
- Terminal app (pre-installed)
- Internet connection
- Admin password (for Homebrew & nvm installs)
Method 1: Install Node.js on macOS Using Homebrew (Fastest & Recommended)
Homebrew is the de-facto package manager for macOS — it installs the latest stable Node.js in seconds.
Step 1 – Install Homebrew (skip if already installed)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Follow prompts → enter password when asked.
Step 2 – Install Node.js
brew install node
This installs the latest LTS (v20 or v22 in 2025–2026) + npm.
Step 3 – Verify installation
node --version
npm --version
Example output (2025–2026):
v22.9.0
10.8.3
Success! You’ve installed Node.js on macOS.
Update anytime:
brew update
brew upgrade node
Method 2: Install Node.js on macOS Using nvm (Best for Multiple Versions)
nvm lets you switch Node versions instantly — perfect for legacy projects, testing new features, or LTS vs current.
Step 1 – Install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
Close & reopen Terminal (or run source ~/.zshrc / source ~/.bash_profile).
Step 2 – Install latest LTS Node.js
nvm install --lts
nvm use --lts
nvm alias default lts/*
Step 3 – Verify
node --version
npm --version
Switch versions anytime:
nvm install 18 # Node 18 LTS
nvm use 18
nvm install node # latest current version
Step 3 – Create & Run Your First Node.js Program
Create a project folder:
mkdir hello-node
cd hello-node
Create index.js:
nano index.js
Paste:
console.log("Hello from Node.js on macOS!");
console.log("Node version:", process.version);
console.log("Current directory:", process.cwd());
Save & exit (Ctrl+O → Enter → Ctrl+X).
Run it:
node index.js
Output:
Hello from Node.js on macOS!
Node version: v22.9.0
Current directory: /Users/zain/hello-node
Success! You’ve written and executed your first Node.js program after installing Node.js on macOS.
Step 4 – Install & Use npm Packages
npm is included — install a package globally:
console.log( 'Code is Poetry' );npm install -g cowsay
cowsay "Node.js is awesome!"
Or locally in your project:
npm init -y
npm install chalk
Create color.js:
const chalk = require('chalk');
console.log(chalk.green('Success! You installed a package.'));
Run:
node color.js
Step 5 – Common macOS Issues & Fixes When Installing Node.js
Homebrew permission error → Run sudo chown -R $(whoami) /usr/local then retry
nvm command not found → Add to ~/.zshrc or ~/.bash_profile:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
Then source ~/.zshrc
Old Node version → nvm ls-remote → nvm install <version>
npm permission issues → Never use sudo npm — fix with:
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
export PATH=~/.npm-global/bin:$PATH
How to Install Node.js on macOS – FAQ (2025–2026)
- How do I install Node.js on macOS?
Best: brew install node (Homebrew) or nvm install –lts (nvm) - Homebrew vs nvm – which to use to install Node.js on macOS?
Homebrew for single version / simplicity; nvm for multiple versions / projects - How do I update Node.js on macOS?
Homebrew: brew upgrade node nvm: nvm install node –reinstall-packages-from=current - How do I run my first Node.js program on macOS?
node index.js after creating index.js - What’s the best Node.js version in 2025–2026?
LTS (v20 or v22) for production; current (v24+) for testing new features
Summary
You now know exactly how to install Node.js on macOS using Homebrew (fast & simple) or nvm (version control), verify installation, create your first program, use npm, and troubleshoot issues.
Mastering how to install Node.js on macOS unlocks modern JavaScript development — React, Next.js, Express, Electron, automation, and more.