Skip to content

Install Node.js on macOS

Essential runtime for AI coding tools

Important

Claude Code and CodeX require Node.js 18+ runtime. If you already have Node.js 18 or later installed, you can skip this section. Verify with: node -v

bash
# Install Homebrew (if 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 --version

Method 2: Official Installer

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

Verify Installation

Open Terminal and run:

bash
node --version
npm --version

If version numbers are displayed (e.g., v18.x.x or higher), the installation was successful.

Troubleshooting

Homebrew Installation Is Slow

You can use a mirror:

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

Permission Issues

If you encounter permission issues, do not use sudo. Instead, fix Homebrew permissions:

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

Next Steps

Environment setup complete! You can now proceed to install Claude Code or CodeX.

Harmony, Kindness, Mutual Help, Happiness