Claude Code Installation Guide
Follow this tutorial to easily install and use Claude Code on your computer.
📍 Choose Your Operating System
🪟 Windows Installation Tutorial
1 Install Node.js Environment
Claude Code requires a Node.js environment to run.
Method 1: Official Download (Recommended)
- Visit Node.js Official Website
- Click "LTS" version to download
- Double-click the
.msi
file and follow the installation wizard - Verify installation:
node --version && npm --version
Method 2: Using Package Manager
# Using Chocolatey
choco install nodejs
# Using Scoop
scoop install nodejs
Verify successful installation
- After installation, open PowerShell or CMD and enter the following commands:
node --version
npm --version
If version numbers are displayed, installation was successful!
2 Install Claude Code
Method 1: PowerShell One-Click Installation (Recommended)
# Run PowerShell as administrator
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
irm https://anthropic.com/claude-code/install.ps1 | iex
Method 2: npm Installation
npm install -g @anthropic/claude-code
3 Set Environment Variables
Configure Claude Code environment variables
To allow Claude Code to connect to your proxy service, you need to set two environment variables:
Method 1: PowerShell Temporary Setting (Current Session)
Run the following commands in PowerShell:
$env:ANTHROPIC_BASE_URL = "your-url"
$env:ANTHROPIC_AUTH_TOKEN = "your-API-key"
💡 Remember to replace "your-API-key" with the actual key you created in the "API Keys" tab above.
Method 2: PowerShell Permanent Setting (User-level)
Run the following commands in PowerShell to set user-level environment variables:
# Set user-level environment variables (permanent)
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", "your-url", [System.EnvironmentVariableTarget]::User)
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_AUTH_TOKEN", "your-API-key", [System.EnvironmentVariableTarget]::User)
View set environment variables:
# View user-level environment variables
[System.Environment]::GetEnvironmentVariable("ANTHROPIC_BASE_URL", [System.EnvironmentVariableTarget]::User)
[System.Environment]::GetEnvironmentVariable("ANTHROPIC_AUTH_TOKEN", [System.EnvironmentVariableTarget]::User)
💡 You need to restart PowerShell window for the settings to take effect.
Verify Environment Variable Settings
After setting environment variables, you can verify if they were set successfully with the following commands:
Verify in PowerShell:
echo $env:ANTHROPIC_BASE_URL
echo $env:ANTHROPIC_AUTH_TOKEN
Verify in CMD:
echo %ANTHROPIC_BASE_URL%
echo %ANTHROPIC_AUTH_TOKEN%
Expected output example:
your-url
cr_xxxxxxxxxxxxxxxxxx
💡 If output is empty or shows the variable name itself, environment variable setting failed, please set again.
4 Start Using Claude Code
Now you can start using Claude Code!
Launch Claude Code
claude
Use in Specific Project
# Navigate to your project directory
cd C:\path\to\your\project
# Launch Claude Code
claude
5 Troubleshooting Common Issues
Issue: "permission denied" error during installation
- This is usually a permission issue, try the following solutions:
- Run PowerShell as administrator
- Or configure npm to use user directory: npm config set prefix %APPDATA%\npm
Issue: claude-code command not found
- Restart PowerShell
- Check if installed as administrator
Issue: PowerShell execution policy error
- If you encounter execution policy restrictions, run:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
🍎 macOS Installation Tutorial
1 Install Node.js Environment
Claude Code requires a Node.js environment to run.
macOS Installation Methods
Method 1: Using Homebrew (Recommended)
If you already have Homebrew installed, using it to install Node.js is more convenient:
# Update Homebrew
brew update
# Install Node.js
brew install node
Method 2: Official Website Download
- Visit https://nodejs.org/
- Download the LTS version for macOS
- Open the downloaded
.pkg
file - Follow the installation program instructions to complete installation
macOS Notes
- If you encounter permission issues, you may need to use sudo
- First run may require permission in System Preferences
- Recommend using Terminal or iTerm2
Verify successful installation
After installation, open Terminal and enter the following commands:
node --version
npm --version
If version numbers are displayed, installation was successful!
2 Install Claude Code
Install Claude Code
Open Terminal and run the following command:
# Global install Claude Code
npm install -g @anthropic-ai/claude-code
If you encounter permission issues, you can use sudo:
sudo npm install -g @anthropic-ai/claude-code
Verify Claude Code Installation
After installation, enter the following command to check if installation was successful:
claude --version
If version number is displayed, congratulations! Claude Code has been successfully installed.
3 Set Environment Variables
Configure Claude Code Environment Variables
To allow Claude Code to connect to your proxy service, you need to set two environment variables:
Method 1: Temporary Setting (Current Session)
Run the following commands in Terminal:
export ANTHROPIC_BASE_URL="your-url"
export ANTHROPIC_AUTH_TOKEN="your-API-key"
💡 Remember to replace "your-API-key" with the actual key you created in the "API Keys" tab above.
Method 2: Permanent Setting
Edit your shell configuration file (depending on your shell):
# For zsh (default)
echo 'export ANTHROPIC_BASE_URL="your-url"' >> ~/.zshrc
echo 'export ANTHROPIC_AUTH_TOKEN="your-API-key"' >> ~/.zshrc
source ~/.zshrc
# For bash
echo 'export ANTHROPIC_BASE_URL="your-url"' >> ~/.bash_profile
echo 'export ANTHROPIC_AUTH_TOKEN="your-API-key"' >> ~/.bash_profile
source ~/.bash_profile
4 Start Using Claude Code
Now you can start using Claude Code!
Launch Claude Code
claude
Use in Specific Project
# Navigate to your project directory
cd /path/to/your/project
# Launch Claude Code
claude
5 Troubleshooting Common Issues
Issue: Permission errors
# Configure npm permissions
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.zshrc
Issue: macOS security settings blocking execution
- If system blocks Claude Code execution:
- Open "System Preferences" → "Security & Privacy"
- Click "Open Anyway" or "Allow"
- Or run in Terminal: sudo spctl --master-disable
Issue: Environment variables not taking effect
- Check the following:
- Confirm you modified the correct configuration file (.zshrc or .bash_profile)
- Restart Terminal
- Verify settings: echo $ANTHROPIC_BASE_URL
🐧 Linux/WSL2 Installation Tutorial
1 Install Node.js Environment
Claude Code requires a Node.js environment to run.
Linux Installation Methods
Method 1: Using Official Repository (Recommended)
# Add NodeSource repository
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
# Install Node.js
sudo apt-get install -y nodejs
Method 2: Using System Package Manager
While version may not be the latest, it's sufficient for basic use:
# Ubuntu/Debian
sudo apt update
sudo apt install nodejs npm
# CentOS/RHEL/Fedora
sudo dnf install nodejs npm
Linux Notes
- Some distributions may need additional dependencies
- If you encounter permission issues, use sudo
- Ensure your user has write permissions to npm global directory
Verify successful installation
After installation, open terminal and enter the following commands:
node --version
npm --version
If version numbers are displayed, installation was successful!
2 Install Claude Code
Install Claude Code
Open terminal and run the following command:
# Global install Claude Code
npm install -g @anthropic-ai/claude-code
If you encounter permission issues, you can use sudo:
sudo npm install -g @anthropic-ai/claude-code
Verify Claude Code Installation
After installation, enter the following command to check if installation was successful:
claude --version
If version number is displayed, congratulations! Claude Code has been successfully installed.
3 Set Environment Variables
Configure Claude Code Environment Variables
To allow Claude Code to connect to your proxy service, you need to set two environment variables:
Method 1: Temporary Setting (Current Session)
Run the following commands in terminal:
export ANTHROPIC_BASE_URL="your-url"
export ANTHROPIC_AUTH_TOKEN="your-API-key"
💡 Remember to replace "your-API-key" with the actual key you created in the "API Keys" tab above.
Method 2: Permanent Setting
Edit your shell configuration file:
# For bash (default)
echo 'export ANTHROPIC_BASE_URL="your-url"' >> ~/.bashrc
echo 'export ANTHROPIC_AUTH_TOKEN="your-API-key"' >> ~/.bashrc
source ~/.bashrc
# For zsh
echo 'export ANTHROPIC_BASE_URL="your-url"' >> ~/.zshrc
echo 'export ANTHROPIC_AUTH_TOKEN="your-API-key"' >> ~/.zshrc
source ~/.zshrc
4 Start Using Claude Code
Now you can start using Claude Code!
Launch Claude Code
claude
Use in Specific Project
# Navigate to your project directory
cd /path/to/your/project
# Launch Claude Code
claude
5 Troubleshooting Common Issues
Issue: Permission error during installation
- Try the following solutions:
- Use sudo for installation: sudo npm install -g @anthropic-ai/claude-code
- Or configure npm to use user directory: npm config set prefix ~/.npm-global
- Then add to PATH: export PATH=~/.npm-global/bin:$PATH
Issue: Missing dependency libraries
- Some Linux distributions need additional dependencies:
# Ubuntu/Debian
sudo apt install build-essential
# CentOS/RHEL
sudo dnf groupinstall "Development Tools"
Issue: Environment variables not taking effect
- Check the following:
- Confirm you modified the correct configuration file (.bashrc or .zshrc)
- Restart terminal or run source ~/.bashrc
- Verify settings: echo $ANTHROPIC_BASE_URL
💡 More Help
Start your AI programming journey! 🎉