Installation
Installation
Section titled “Installation”Claude Code runs as a CLI tool on top of Node.js. Here’s the complete setup for every platform.
Step 1 — Install Node.js
Section titled “Step 1 — Install Node.js”Claude Code requires Node.js v18 or higher. Use v20 LTS or v22 for best results.
Mac (Homebrew):
brew install nodeWindows: Download the installer from nodejs.org. During install, check “Add to PATH”.
Linux (Ubuntu/Debian):
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -sudo apt-get install -y nodejsVerify the install:
node --version # should print v20.x.x or highernpm --version # should print 10.x.x or higherStep 2 — Install Claude Code
Section titled “Step 2 — Install Claude Code”npm install -g @anthropic-ai/claude-codeVerify:
claude --versionYou should see a version number like 1.x.x.
Step 3 — Get an Anthropic API Key
Section titled “Step 3 — Get an Anthropic API Key”- Go to console.anthropic.com
- Sign up or log in
- Click API Keys in the left sidebar
- Click Create Key
- Copy the key — it starts with
sk-ant-
Important: You only see the key once. Save it somewhere safe.
Step 4 — Set the API Key
Section titled “Step 4 — Set the API Key”Mac / Linux (add to shell profile so it persists):
echo 'export ANTHROPIC_API_KEY=sk-ant-YOUR-KEY-HERE' >> ~/.zshrcsource ~/.zshrcOr for bash:
echo 'export ANTHROPIC_API_KEY=sk-ant-YOUR-KEY-HERE' >> ~/.bashrcsource ~/.bashrcWindows (PowerShell, persistent):
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_API_KEY", "sk-ant-YOUR-KEY-HERE", "User")Then restart your terminal.
For a single session only (any platform):
export ANTHROPIC_API_KEY=sk-ant-YOUR-KEY-HEREStep 5 — Verify Everything Works
Section titled “Step 5 — Verify Everything Works”claude --version # shows version numberecho $ANTHROPIC_API_KEY # shows your key (Mac/Linux)Then start your first session:
mkdir test-project && cd test-projectclaudeYou should see the Claude Code prompt. Type /help to see available commands.
VS Code Integration (Optional but Recommended)
Section titled “VS Code Integration (Optional but Recommended)”Claude Code integrates with VS Code so you can trigger sessions from the editor.
- Open VS Code
- Open the Command Palette (
Ctrl+Shift+P/Cmd+Shift+P) - Type “Claude Code” — install the extension if prompted
- Use
Ctrl+Shift+C(Cmd+Shift+Con Mac) to open a Claude Code session in the terminal
Pricing Note
Section titled “Pricing Note”Claude Code uses your Anthropic API key and bills per token. For typical learning sessions (one new app per session, moderate complexity), expect $0.10–$1.00 per session. Claude Sonnet is the default model — more affordable than Claude Opus while still highly capable.
Set a spending limit in the Anthropic console under Billing to avoid surprises.
Troubleshooting
Section titled “Troubleshooting”“command not found: claude” after install
npm’s global bin directory isn’t in your PATH. Fix:
npm config get prefix # shows where global packages are installed# add that path + /bin to your PATH“Invalid API key”
Double-check the key in the Anthropic console. Make sure there are no extra spaces or newline characters in the variable.
Windows: PowerShell execution policy
If you see a policy error:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUserNext: Your First Session