Home / AI / Claude AI / How to Install Claude Code on Mac (Step-by-Step Guide)

How to Install Claude Code on Mac (Step-by-Step Guide)

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 node

Alternatively, download the macOS installer directly from nodejs.org and run the .pkg file.

Verify the install:

node --version
npm --version

Both should return version numbers.

Step 2: Get Your Anthropic API Key

  1. Go to console.anthropic.com and sign in or create a free account.
  2. Click API Keys in the left menu.
  3. Click Create Key, name it (e.g. “Claude Code Mac”), and copy the key immediately — you won’t be able to view it again.
  4. 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-code

If you get a permissions error, use:

sudo npm install -g @anthropic-ai/claude-code

Enter 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 ~/.zshrc

If you’re using bash instead:

echo 'export ANTHROPIC_API_KEY="your-api-key-here"' >> ~/.bash_profile
source ~/.bash_profile

Replace your-api-key-here with your actual key.

Step 5: Launch Claude Code

Navigate to a project folder:

cd ~/Projects/my-project

Then start Claude Code:

claude

Accept 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 ~/.zshrc to reload your PATH.
  • “API key not set” error — run echo $ANTHROPIC_API_KEY to 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.

Sign Up For Daily Newsletter

Stay updated with our weekly newsletter. Subscribe now to never miss an update!

[mc4wp_form]

Leave a Reply

Your email address will not be published. Required fields are marked *