Skip to content

Install Node.js on macOS

The required runtime environment for the three major AI coding tools.

Important

Claude Code and Codex CLI both require Node.js 18+. If Node.js 18 or later is already installed, you can skip this section.

Verification command: node -v

Method 1: Homebrew Package Manager (Recommended)

sh
# Install Homebrew if it is not installed
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install Node.js
brew install node

# Verify installation
node --version
npm --version

Method 2: Official Installer

  1. Visit the Node.js website: https://nodejs.org
  2. Download the LTS .pkg installer.
  3. Run the installer and follow the prompts.

Verify Installation

Open Terminal and run:

sh
node --version
npm --version

If version numbers are displayed, such as v18.x.x or later, the installation is successful.

FAQ

Homebrew installation is slow

You can use a mirror:

sh
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"

Permission issues

If you encounter permission issues, do not install Node.js with sudo directly. Fix Homebrew permissions first:

sh
sudo chown -R $(whoami) /usr/local/bin /usr/local/lib

Next Steps

✅ Environment ready!

You can now continue installing Claude Code, Codex CLI, Codex Desktop, or OpenCode.