Skip to main content

Requirements

  • Node.js 18 or later
  • npm 8 or later (included with Node.js)
  • Operating system: macOS, Linux, or Windows (via WSL2)
macOS 12 (Monterey) or later is recommended. The npm installation works on both Intel and Apple Silicon.If you use Homebrew to manage Node.js, install it first:
Then install Claude Code:

Authenticate

Run the /login command to sign in with your Anthropic account:
Claude Code opens a browser window and starts an OAuth 2.0 flow. You can authenticate with:
  • Claude Pro or Max subscription — sign in via claude.ai
  • Anthropic Console (API billing) — sign in via console.anthropic.com
After you authorize in the browser, your credentials are stored securely (macOS Keychain on macOS, or an encrypted local file on Linux and Windows/WSL). You only need to run /login once, or when you want to switch accounts.

API key alternative

If you prefer to authenticate with an API key directly instead of OAuth, set the ANTHROPIC_API_KEY environment variable:
Add this line to your shell profile (~/.zshrc, ~/.bashrc, etc.) to make it permanent. When this variable is set, Claude Code uses it instead of the stored OAuth token.

Verify your setup

Run the /doctor command to check that everything is configured correctly:
/doctor shows:
  • Your Claude Code version and installation type
  • Whether auto-updates are enabled
  • Your ripgrep status (used for fast codebase search)
  • Any configuration warnings with suggested fixes
A healthy setup shows no warnings. If /doctor reports an issue, it also tells you how to fix it.

Troubleshooting

Your npm global bin directory may not be in your PATH. Find it with:
Then add <prefix>/bin to your PATH. For example:
Avoid using sudo npm install -g. Instead, configure npm to use a directory you own:
Or use a Node.js version manager like nvm, which avoids the permission issue entirely.
If the browser does not open automatically, Claude Code displays the login URL in the terminal. Copy and paste it into your browser manually.If the OAuth flow fails with an SSL error, check whether a corporate proxy or VPN is intercepting HTTPS traffic. You may need to configure your proxy settings or use an API key instead.
If you have both an npm global install and a native install, /doctor will warn you. Remove the one you are not using:
Then re-run claude /doctor to confirm the warning is resolved.
Claude Code uses ripgrep for fast file search. If /doctor reports a ripgrep problem, install it with your system package manager:
Claude Code also ships with a built-in fallback, so most search operations still work even if the system ripgrep is unavailable.
Do not run sudo npm install -g @anthropic-ai/claude-code. Installing with sudo can cause permission issues with auto-updates and is a security risk. Use a version manager or configure a user-owned npm prefix instead.

Next steps

Quick Start

Run your first Claude Code session

How it works

Understand the permission model and tool system