Skip to content
Runbook

Install Node.js on macOS

Server-side JavaScript runtime, built on the V8 engine, shipped with the npm package manager.

Runtimejavascriptruntimebackendv8npm

Installation

Homebrew (latest) · Homebrew
brew install node

Installs the current version of Node.js packaged by Homebrew, with npm.

nvm (multiple versions) · Homebrew
brew install nvm
export NVM_DIR="$HOME/.nvm"
. "$(brew --prefix nvm)/nvm.sh"
nvm install --lts

To manage multiple versions; requires initializing nvm in your shell (see notes).

Verify the installation

Verify
node --version

Important files

TypePathDescription
config~/.npmrcUser configuration for npm (registry, proxy, authentication tokens).

Command-line tools

  • nodeThe JavaScript runtime.
  • npmNode.js package manager.
  • npxRuns a package binary without installing it globally.

Uninstall

Uninstall (Homebrew)
brew uninstall node
Uninstall (nvm)
brew uninstall nvm
rm -rf ~/.nvm

Also remove the nvm lines from ~/.zshrc; ~/.npmrc and global packages remain.

Good to know

  • To manage multiple versions of Node.js, use nvm ("nvm install --lts") or fnm.
  • For a specific LTS version with Homebrew, install a versioned formula such as "brew install node@24" (there is no node@lts formula).
  • Homebrew's "node" formula no longer includes Corepack; install it separately with "brew install corepack" if you need it, then run "corepack enable".
  • With nvm, add its loading to your ~/.zshrc: "export NVM_DIR=\"$HOME/.nvm\"" then "[ -s \"/opt/homebrew/opt/nvm/nvm.sh\" ] && . \"/opt/homebrew/opt/nvm/nvm.sh\"".

Installation on macOS

The simplest method is Homebrew: brew install node installs the runtime and npm in one command. This formula tracks the current version of Node.js, not the LTS; to pin a long-term support release, install a versioned formula such as brew install node@24 (there is no node@lts formula). The binary is located in /opt/homebrew/bin/node on Apple Silicon Macs (M1 and later) and in /usr/local/bin/node on Intel Macs. Check your PATH if the node command is not found after installation.

Managing multiple versions

If your projects require different versions of Node.js, do not install the global Homebrew package: use a version manager such as nvm or fnm instead. This avoids conflicts and lets you switch per project with a .nvmrc file. nvm is a shell function that must be sourced: after brew install nvm, run export NVM_DIR="$HOME/.nvm" then . "$(brew --prefix nvm)/nvm.sh" before nvm install --lts, and add those lines to your ~/.zshrc for future sessions. Note that Homebrew's node formula and an nvm installation can conflict in the PATH; choose a single approach.

Configuration and cleanup

The ~/.npmrc file stores npm's configuration (private registry, proxy, authentication token). Globally installed packages reside in the npm prefix (often /opt/homebrew/lib/node_modules). Homebrew's node formula no longer includes Corepack: to enable pnpm or yarn, first install it with brew install corepack, then run corepack enable. To uninstall an nvm installation, run brew uninstall nvm, remove the directory with rm -rf ~/.nvm, and delete the nvm lines from your ~/.zshrc; note that ~/.npmrc and globally installed packages remain.