Install Node.js on macOS
Essential Runtime Environments for the Three Major AI Coding Tools
💡 Important Note
Claude Code, CodeX, and Gemini CLI all require Node.js 18+ to run. If you have already installed Node.js 18 or later, you can skip this section. Verification command: node -v
Method 1: Homebrew Package Manager (Recommended)
# Install Homebrew (if it is not already 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 Installation Package
- Visit the Node.js official website: https://nodejs.org
- Download the LTS
.pkginstaller - Run the installer and follow the prompts to complete the installation
Verify installation
Open a terminal and run:
node --version
npm --versionIf a version number is displayed (such as v18.x.x or later), the installation was successful.
Frequently Asked Questions
Slow Homebrew Installation
You can use a domestic mirror:
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"Permission issues
If you run into permission issues, do not use sudo; instead, fix your Homebrew permissions:
sudo chown -R $(whoami) /usr/local/bin /usr/local/libNext steps
✅ Environment setup complete!
You can now continue installing Claude Code, CodeX, or Gemini CLI.