Requirements
| Requirement | Minimum version |
|---|
| Node.js | 18.0.0 |
| npm | Included 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 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.
On Linux, credentials are stored in a local configuration file rather than a system keychain. The file is created at:~/.config/claude-code/credentials.json
Protect this file with appropriate permissions:chmod 600 ~/.config/claude-code/credentials.json
Do not commit this file to version control or share it. It contains your OAuth token.
Make sure ripgrep (rg) is installed for the best search performance. Claude Code falls back to slower alternatives if rg is not available.# Debian/Ubuntu
apt install ripgrep
# Fedora
dnf install ripgrep
# Arch
pacman -S ripgrep
Claude Code runs on Windows via WSL 2 (Windows Subsystem for Linux). A native Windows binary is not currently available.Enable WSL 2
Restart your machine if prompted. Open a WSL terminal
Launch your WSL distribution (Ubuntu is the default) from the Start menu or by running wsl in PowerShell.
Install Node.js inside WSL
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
Install Claude Code
npm install -g @anthropic-ai/claude-code
Run Claude Code from within a WSL terminal, not from a Windows Command Prompt or PowerShell window. File paths, shell commands, and git operations all run in the Linux environment.
Authentication setup
Claude Code uses OAuth 2.0 to authenticate with your Anthropic account.
First-time setup:
- Run
claude to open the REPL.
- Type
/login at the prompt.
- Your browser opens the Anthropic authorization page.
- 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:
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
rm -rf ~/.config/claude-code
Verifying the installation
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:
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.