Install Node.js on macOS
Introduction
This chapter shows you how to install Node.js on macOS in a reliable way for real projects. You will choose between Homebrew and the official installer, verify node and npm, and avoid common PATH conflicts. A clean setup early prevents confusing version errors when you run tutorials or team repositories.
Prerequisites
- A Mac running a recent macOS version (Ventura, Sonoma, or newer recommended)
- Basic Terminal knowledge (
cd,ls, running commands) - Internet access for Homebrew or the official installer
- Completed What Is JavaScript (conceptual overview)
Choose an Installation Method
On macOS, the two most practical options are Homebrew and the official .pkg installer from nodejs.org.
Recommended strategy:
- Use Homebrew for easy upgrades and consistency with other dev tools
- Use the official installer if your team standard requires it
- Avoid relying on outdated global
nodebinaries left from old experiments
Warning
Do not assume macOS ships a modern Node.js for development. Always install and verify an LTS release you control.
Install Node.js with Homebrew (Recommended)
If Homebrew is not installed, set it up from brew.sh first.
# Refresh Homebrew metadata
brew update
# Install Node.js (includes npm)
brew install node
# Verify Node.js version
node --version
# Verify npm version
npm --versionTip
Best Practice
After brew install node, run which node and confirm it points under /opt/homebrew (Apple Silicon) or /usr/local (Intel), not an unexpected old path.
Install Node.js from nodejs.org (Alternative)
- Download the LTS macOS installer (
.pkg) from nodejs.org - Run the package and complete the wizard with default options unless your team specifies otherwise
- Open a new Terminal window
- Verify:
# Verify Node.js version
node --version
# Verify npm version
npm --versionOptional: Manage Multiple Versions with nvm
If you need several Node.js versions on one Mac (different client projects, legacy apps), use nvm:
# Example: install nvm (see https://github.com/nvm-sh/nvm for latest install command)
# Then install and use an LTS version
nvm install --lts
nvm use --lts
node --versionStart with a single LTS install unless you already know you need nvm.
FAQ
Should I use node or nodejs on macOS?
The command is node on macOS when installed from Homebrew or nodejs.org. Some Linux distros expose nodejs as a separate package name—macOS setups in this course use node.
Is Homebrew better than the official installer?
For many developers, Homebrew simplifies upgrades (brew upgrade node). The official installer is still valid if your organization standardizes on it.
Why does Terminal show an old Node version after install?
PATH order may prefer an older binary. Run which -a node and remove or reprioritize stale installs. Open a fresh Terminal tab after changes.
Do I need sudo for npm global installs?
Prefer local project installs (npm install inside a project) over global tools when learning. If you install global CLIs, understand permissions; many teams use npx instead of global installs.
Can I use Node.js without installing anything for browser-only learning?
Browser DevTools run JavaScript without Node.js, but this tutorial track uses Node.js for scripts, tooling, and later chapters. Install Node.js for the full path.