How to Install Claude Code on Mac, Windows, and Linux
Complete installation guide for Claude Code across all major operating systems.
Claude Code runs in your terminal and works on macOS, Windows, and Linux. Here’s how to install it on each platform.
Prerequisites
Before installing Claude Code, you need:
- Node.js 18+ - Check with
node --version - An Anthropic API key - Get one at console.anthropic.com
macOS Installation
Using npm (Recommended)
npm install -g @anthropic-ai/claude-code
Using Homebrew
brew install claude-code
Verify Installation
claude --version
Set Your API Key
echo 'export ANTHROPIC_API_KEY="your-key-here"' >> ~/.zshrc
source ~/.zshrc
Windows Installation
Using npm
Open PowerShell as Administrator:
npm install -g @anthropic-ai/claude-code
Set Your API Key
[System.Environment]::SetEnvironmentVariable('ANTHROPIC_API_KEY', 'your-key-here', 'User')
Restart your terminal after setting the environment variable.
Verify Installation
claude --version
Windows Subsystem for Linux (WSL)
For a better experience on Windows, consider using WSL:
# In WSL
npm install -g @anthropic-ai/claude-code
echo 'export ANTHROPIC_API_KEY="your-key-here"' >> ~/.bashrc
source ~/.bashrc
Linux Installation
Using npm
npm install -g @anthropic-ai/claude-code
Set Your API Key
For bash:
echo 'export ANTHROPIC_API_KEY="your-key-here"' >> ~/.bashrc
source ~/.bashrc
For zsh:
echo 'export ANTHROPIC_API_KEY="your-key-here"' >> ~/.zshrc
source ~/.zshrc
Verify Installation
claude --version
Common Installation Issues
EACCES Permission Error
If you see permission errors with npm:
# Option 1: Use a node version manager
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
nvm install 20
nvm use 20
npm install -g @anthropic-ai/claude-code
# Option 2: Change npm's default directory
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
npm install -g @anthropic-ai/claude-code
Command Not Found
If claude command isn’t found after installation:
- Check if npm global bin is in your PATH:
npm bin -g
- Add it to your PATH if missing:
echo 'export PATH="$(npm bin -g):$PATH"' >> ~/.bashrc
source ~/.bashrc
Node.js Version Too Old
Claude Code requires Node.js 18 or later:
# Check your version
node --version
# If too old, update using nvm
nvm install 20
nvm use 20
SSL Certificate Errors
On corporate networks with SSL inspection:
npm config set strict-ssl false
npm install -g @anthropic-ai/claude-code
npm config set strict-ssl true
First Run
After installation, start Claude Code:
claude
On first run, Claude will:
- Verify your API key
- Ask about permissions
- Show the interactive prompt
Try a simple command:
Hello, can you tell me what directory I'm in?
Updating Claude Code
To update to the latest version:
npm update -g @anthropic-ai/claude-code
Or reinstall:
npm install -g @anthropic-ai/claude-code@latest
Uninstalling
If you need to remove Claude Code:
npm uninstall -g @anthropic-ai/claude-code
IDE Integration (Optional)
VS Code
Install the Claude Code extension from the VS Code marketplace:
- Open VS Code
- Go to Extensions (Cmd+Shift+X)
- Search for “Claude Code”
- Install
JetBrains
- Open Settings/Preferences
- Go to Plugins
- Search for “Claude Code”
- Install and restart
Next Steps
After installation: