Installing Claude Code on a Mac is straightforward — most Macs already have the tools you need, and the whole process takes under ten minutes. Here’s exactly how to do it.
What You Need Before Starting
- macOS 12 (Monterey) or later
- Node.js 18 or higher
- An Anthropic API key — free to generate at console.anthropic.com
Step 1: Install Node.js
The easiest way on Mac is via Homebrew. If you don’t have Homebrew, install it first by opening Terminal and running:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"Then install Node.js:
brew install nodeAlternatively, download the macOS installer directly from nodejs.org and run the .pkg file.
Verify the install:
node --version
npm --versionBoth should return version numbers.
Step 2: Get Your Anthropic API Key
- Go to console.anthropic.com and sign in or create a free account.
- Click API Keys in the left menu.
- Click Create Key, name it (e.g. “Claude Code Mac”), and copy the key immediately — you won’t be able to view it again.
- Add a payment method in the Billing section. Anthropic gives new accounts free credits so you won’t be charged to get started.
Step 3: Install Claude Code
Open Terminal and run:
npm install -g @anthropic-ai/claude-codeIf you get a permissions error, use:
sudo npm install -g @anthropic-ai/claude-codeEnter your Mac password when prompted.
Step 4: Set Your API Key
Add your API key to your shell profile so it loads automatically every time you open Terminal. For most Macs running zsh (the default since macOS Catalina):
echo 'export ANTHROPIC_API_KEY="your-api-key-here"' >> ~/.zshrc
source ~/.zshrcIf you’re using bash instead:
echo 'export ANTHROPIC_API_KEY="your-api-key-here"' >> ~/.bash_profile
source ~/.bash_profileReplace your-api-key-here with your actual key.
Step 5: Launch Claude Code
Navigate to a project folder:
cd ~/Projects/my-projectThen start Claude Code:
claudeAccept the terms of service on first run, and you’re in. Try a quick test:
claude "describe what this project does based on the files here"Apple Silicon (M1/M2/M3) Notes
Claude Code runs natively on Apple Silicon — no Rosetta required. If you installed Node.js via Homebrew on an Apple Silicon Mac and get architecture-related errors, make sure you’re using the ARM version of Homebrew (installed at /opt/homebrew rather than /usr/local). Run which brew to check.
Troubleshooting
- “command not found: claude” — close and reopen Terminal, or run
source ~/.zshrcto reload your PATH. - “API key not set” error — run
echo $ANTHROPIC_API_KEYto check the variable is set. If it’s empty, re-run the export command above. - Slow first response — normal on first run while Claude Code initialises. Subsequent responses are faster.
Related Guides
- How to Install Claude Code on Windows
- How to Use Claude Code — Beginner’s Guide
- CLAUDE.md Explained — Configure Claude Code for Your Project