Install Node.js on macOS
Required runtime for the three main AI coding tools.
Important
Claude Code, CodeX, and Gemini CLI all require Node.js 18+. If Node.js 18 or later is already installed, you can skip this page. Check with node -v.
Method 1: Homebrew Package Manager (Recommended)
bash
# 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 --versionMethod 2: Official Installer
- Visit the Node.js website: https://nodejs.org
- Download the LTS
.pkginstaller - Run the installer and follow the prompts
Verify Installation
Open Terminal and run:
bash
node --version
npm --versionIf version numbers are shown, such as v18.x.x or later, installation succeeded.
FAQ
Homebrew Installation Is Slow
You can use a local mirror:
bash
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"Permission Issues
If you encounter permission problems, do not use sudo for Homebrew. Fix Homebrew permissions instead:
bash
sudo chown -R $(whoami) /usr/local/bin /usr/local/libNext Steps
Environment Ready
You can now install Claude Code, CodeX, or Gemini CLI.