Skip to main content

Requirements

  • Node.js 18 or higher (node --version to check)
  • Supported platforms: macOS, Linux, Windows (including WSL)
On Windows, running Claude Code natively via WSL (Windows Subsystem for Linux) is the recommended path. Ensure you use a Linux-native Node.js and npm installation inside WSL — not the Windows versions from /mnt/c/. See the Windows note below.

Install the package

Install @anthropic-ai/claude-code globally so the claude command is available anywhere on your system.
npm install -g @anthropic-ai/claude-code

Install locally in a project

You can also install Claude Code as a local dev dependency and run it via npx:
npm install --save-dev @anthropic-ai/claude-code
npx claude

Verify the installation

claude --version
The command prints the installed version and exits.

Authentication

Claude Code supports several authentication methods. Configure one before your first session. Run claude from any directory. If no credentials are found, Claude Code launches an interactive OAuth flow:
claude
Follow the URL printed in your terminal to log in with your claude.ai account. Claude Code stores the resulting token locally. A Claude subscription is required for this flow. To set up a long-lived token explicitly, run:
claude setup-token

2. API key via environment variable

Set ANTHROPIC_API_KEY in your shell before running claude. Claude Code reads this variable at startup and skips the OAuth flow:
export ANTHROPIC_API_KEY=sk-ant-...
claude
Add the export to your shell profile (~/.bashrc, ~/.zshrc, etc.) to make it permanent.
If ANTHROPIC_API_KEY is set, Claude Code will not use an existing OAuth session. Clear the variable to switch back to OAuth.

3. Amazon Bedrock

Set CLAUDE_CODE_USE_BEDROCK=1 to route all API calls through Amazon Bedrock. Standard AWS credential resolution applies (environment variables, ~/.aws/credentials, IAM instance roles, etc.):
export CLAUDE_CODE_USE_BEDROCK=1
claude

4. Google Vertex AI

Set CLAUDE_CODE_USE_VERTEX=1 to route all API calls through Google Vertex AI. Standard Google Cloud credential resolution applies:
export CLAUDE_CODE_USE_VERTEX=1
claude

Auto-updater

Claude Code checks for updates automatically and installs them in the background using npm install -g (or bun install -g when running under Bun). The updater requires write access to your global npm prefix directory.

Disable the auto-updater

Set DISABLE_AUTOUPDATER=1 in your environment to opt out of automatic updates:
export DISABLE_AUTOUPDATER=1
You can also add this to your shell profile to make it permanent. To update manually when the auto-updater is disabled, run:
claude update

Windows and WSL

On Windows, the auto-updater requires a Linux-native npm installation. If Claude Code detects that npm is being resolved from the Windows path (e.g. /mnt/c/...), the update will fail. Install Node.js inside your Linux distribution and ensure the Linux npm appears first in PATH:
# Example: install Node.js in Ubuntu/Debian WSL
sudo apt install nodejs npm

System CA certificates

Claude Code uses the system’s TLS stack for all API calls. In environments with custom or corporate CA certificates (e.g. TLS-intercepting proxies), you may need to supply additional certificates.

NODE_EXTRA_CA_CERTS

Point NODE_EXTRA_CA_CERTS to a PEM-format CA bundle file. Claude Code appends these certificates to the built-in Mozilla root store:
export NODE_EXTRA_CA_CERTS=/path/to/corporate-ca-bundle.pem

—use-system-ca

Pass --use-system-ca in NODE_OPTIONS to use the operating system’s CA store instead of the bundled Mozilla roots:
export NODE_OPTIONS="--use-system-ca"
You can combine both options: --use-system-ca selects system CAs as the base, and NODE_EXTRA_CA_CERTS appends additional certificates on top.
If you see SSL certificate errors mentioning *.anthropic.com, set NODE_EXTRA_CA_CERTS to your corporate CA bundle path or ask your IT team to allowlist the Anthropic API endpoints.

Configuration directory

Claude Code stores its configuration, session data, and credentials in ~/.claude/ by default. Override this with the CLAUDE_CONFIG_DIR environment variable:
export CLAUDE_CONFIG_DIR=/custom/path/.claude

Uninstall

Remove the global package with the package manager you used to install it:
npm uninstall -g @anthropic-ai/claude-code
You can also remove the configuration directory if you want to delete stored credentials and settings:
rm -rf ~/.claude

Build docs developers (and LLMs) love