Skip to main content

Requirements

RequirementMinimum version
Node.js18.0.0
npmIncluded with Node.js 18+
Bun (optional)Any recent stable release
Claude Code is distributed as an npm package. You do not need Bun to install or run the pre-built binary — Bun is only required if you are building from source.

Install

npm install -g @anthropic-ai/claude-code
After installation, verify it is available:
claude --version

Platform notes

Claude Code stores OAuth credentials in the macOS Keychain. No extra configuration is needed — the keychain integration is automatic.Two keychain entries are prefetched at startup to reduce authentication latency:
  • The OAuth token for your Anthropic account
  • A legacy API key slot (used when ANTHROPIC_API_KEY is set)
If you see a Keychain permission dialog on first run, click Allow. This grants Claude Code access to store and retrieve your credentials securely.
If you are on an Apple Silicon Mac and see a crash on startup, make sure you are running a native arm64 build of Node.js, not an x86_64 build under Rosetta.

Authentication setup

Claude Code uses OAuth 2.0 to authenticate with your Anthropic account. First-time setup:
  1. Run claude to open the REPL.
  2. Type /login at the prompt.
  3. Your browser opens the Anthropic authorization page.
  4. Approve access and return to the terminal.
Claude Code stores the resulting token securely (Keychain on macOS, a local file on Linux) and refreshes it automatically. You do not need to repeat this process unless you explicitly log out or revoke access. API key alternative: If you prefer not to use OAuth, set the ANTHROPIC_API_KEY environment variable before launching Claude Code:
export ANTHROPIC_API_KEY="sk-ant-..."
claude
When an API key is present, the /login command switches between accounts rather than initiating a new OAuth flow. Logging out:
/logout
This revokes the stored token and clears the local credential cache.

Upgrading

npm update -g @anthropic-ai/claude-code
Claude Code also has a built-in auto-updater that runs in the background. If a new version is available, you will see a notification in the REPL. You can disable auto-updates in your settings if you prefer to control upgrades manually.

Uninstalling

npm uninstall -g @anthropic-ai/claude-code
To also remove stored credentials and configuration:
# Remove configuration directory
rm -rf ~/Library/Application\ Support/claude-code

# Remove Keychain entries (optional)
security delete-generic-password -s "claude-code" 2>/dev/null || true

Verifying the installation

claude --version
If the command is not found after a global npm install, your npm global bin directory may not be on your PATH. Find it with:
npm bin -g
Then add that directory to your shell’s PATH in ~/.bashrc, ~/.zshrc, or equivalent:
export PATH="$(npm bin -g):$PATH"
Run /doctor inside the Claude Code REPL for a comprehensive health check that covers authentication, runtime versions, network access, and configuration.

Build docs developers (and LLMs) love