Skip to main content

Requirements

RequirementVersion
Node.js18 or later
npmBundled with Node.js 18+
Operating systemmacOS, Linux, or Windows (WSL2 recommended)
Check your Node.js version:
node --version
Claude Code is distributed as an npm package and requires Node.js 18+. If you are on an older version, upgrade via your system package manager or a version manager (see below).

Install Claude Code

npm install -g @anthropic-ai/claude-code
Verify the installation:
claude --version
You should see output like 1.x.x (Claude Code).
Do not use sudo npm install -g on macOS or Linux. If you get a permissions error, fix your npm prefix instead (see the npm docs).

Platform-specific setup

Install Node.js on macOS

Option 1 — Homebrew (recommended)
brew install node
Option 2 — nvm (Node Version Manager)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
# Open a new terminal, then:
nvm install --lts
nvm use --lts
Option 3 — Official installerDownload the macOS installer from nodejs.org.

Install Claude Code

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

macOS keychain integration

On macOS, Claude Code stores OAuth tokens in the macOS Keychain via security CLI. This is automatic — no extra setup is required. If you see a keychain access prompt the first time you log in, click Allow.

Authentication setup

Claude Code supports multiple authentication methods. Choose the one that matches your access type.

Claude.ai OAuth (Pro / Team)

If you have a Claude.ai Pro or Team subscription, you can authenticate with your account directly.
1

Run claude

claude
2

Select Claude.ai login

When prompted, choose Claude.ai (not API key). Claude Code will open a browser window.
3

Complete the OAuth flow

Sign in to claude.ai and authorize Claude Code. Return to the terminal when done.
Your OAuth tokens are stored in the system keychain and refreshed automatically. You will not need to re-authenticate unless you explicitly log out. To log out:
claude logout

Anthropic API key

If you access the API directly through console.anthropic.com, use an API key:
export ANTHROPIC_API_KEY=sk-ant-...
claude
To persist the key across sessions, add the export line to your shell profile:
export ANTHROPIC_API_KEY=sk-ant-...
Then reload your shell:
source ~/.zshrc   # or source ~/.bashrc
Do not commit your API key to version control. Use a secrets manager or a .env file excluded from git.

Amazon Bedrock

Access Claude through AWS Bedrock using your existing AWS credentials:
export CLAUDE_CODE_USE_BEDROCK=1
claude
Claude Code uses the AWS SDK’s standard credential chain — environment variables, ~/.aws/credentials, IAM roles, and so on. Make sure the IAM identity you are using has permission to invoke the Claude model on Bedrock. Additional environment variables for Bedrock:
VariablePurpose
AWS_PROFILENamed AWS profile to use
AWS_REGIONAWS region for Bedrock requests
CLAUDE_CODE_SKIP_BEDROCK_AUTHSkip credential prefetch (useful in some IAM role setups)

Google Vertex AI

Access Claude through GCP Vertex AI:
export CLAUDE_CODE_USE_VERTEX=1
claude
Claude Code authenticates using Application Default Credentials (ADC). Set up ADC with:
gcloud auth application-default login
Additional environment variables:
VariablePurpose
GOOGLE_CLOUD_PROJECTGCP project ID
CLAUDE_VERTEX_REGIONVertex AI region
CLAUDE_CODE_SKIP_VERTEX_AUTHSkip credential prefetch

Enterprise and proxy configuration

Custom API base URL

To route Claude Code through an API gateway or proxy, set:
export ANTHROPIC_BASE_URL=https://your-proxy.example.com

Custom CA certificates

If your network uses a corporate CA:
export NODE_EXTRA_CA_CERTS=/path/to/ca-bundle.crt
Or enable system CA roots:
NODE_OPTIONS="--use-system-ca" claude

Managed settings

Enterprise administrators can distribute a policy settings file to all users. Set the path via:
export CLAUDE_CODE_SETTINGS_FILE=/etc/claude-code/policy.json
See Configuration for the full settings schema.

Verify your installation

Run the built-in diagnostics command to check for common problems:
claude doctor
This checks Node.js version, authentication state, keychain access, network connectivity, and MCP server configuration. Any issues are printed with suggested fixes.

Update Claude Code

npm update -g @anthropic-ai/claude-code
Claude Code also checks for updates automatically at startup and prompts you when a new version is available. To disable auto-updates:
export CLAUDE_CODE_DISABLE_AUTO_UPDATER=1
Or from within a session:
> /upgrade

Uninstall

npm uninstall -g @anthropic-ai/claude-code
Configuration and session data are stored separately in ~/.claude/. Remove that directory if you want to delete all local state:
rm -rf ~/.claude

Next steps

Quickstart

Walk through your first Claude Code session.

Introduction

Understand how Claude Code works under the hood.

Configuration

Customize behavior with settings files and environment variables.

CLI flags

Full reference for every command-line flag.

Build docs developers (and LLMs) love