📦 Claude Code Installation Guide
Complete guide for Windows / macOS / Linux - from environment setup to first run.
🎯 Choose Your Operating System
🪟 Windows Installation
Step 1: Install Node.js Environment
Claude Code requires Node.js environment to run.
Method 1: Using Official Installer (Recommended)
- Visit https://nodejs.org/
- Click to download "LTS" version (Recommended)
- Download Windows Installer (.msi)
- Run the installer, keep default settings
- Restart your computer after installation
Method 2: Using Chocolatey Package Manager
If you already have Chocolatey installed, you can install via command line:
# Run PowerShell as Administrator
choco install nodejs
Windows Notes
- Environment variables will be configured automatically during installation
- PowerShell is recommended over CMD
- Some enterprise environments may require administrator privileges
Verify Installation Success
After installation, open PowerShell and enter the following commands:
node --version
npm --version
If version numbers are displayed, installation was successful!
Step 2: Install Claude Code
Open PowerShell (recommended to run as Administrator) and run the following command:
# Install Claude Code globally
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 the version number is displayed, congratulations! Claude Code has been successfully installed.
Step 3: Set Environment Variables
To connect Claude Code to your relay service, you need to set two environment variables.
Method 1: Temporary Setup (Current Session)
Run the following commands in PowerShell:
$env:ANTHROPIC_BASE_URL = "https://use.codecodex.ai/api"
$env:ANTHROPIC_AUTH_TOKEN = "your-api-key"
💡 Remember to replace "your-api-key" with the actual key created in the admin portal "API Keys" tab.
Method 2: Permanent Setup
Using System Settings (GUI):
- Right-click "This PC" → "Properties"
- Click "Advanced system settings"
- Click "Environment Variables"
- In "User variables" click "New" and add:
- Variable name:
ANTHROPIC_BASE_URL - Variable value:
https://use.codecodex.ai/api
- Variable name:
- Click "New" again and add:
- Variable name:
ANTHROPIC_AUTH_TOKEN - Variable value:
your-api-key
- Variable name:
- Click "OK" to save
Using PowerShell (Permanent Setup):
# Set user-level environment variables
[Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", "https://use.codecodex.ai/api", "User")
[Environment]::SetEnvironmentVariable("ANTHROPIC_AUTH_TOKEN", "your-api-key", "User")
Verify Environment Variable Setup
Reopen PowerShell and run the following commands to verify settings:
echo $env:ANTHROPIC_BASE_URL
echo $env:ANTHROPIC_AUTH_TOKEN
Expected Output Example:
https://use.codecodex.ai/api
cr_xxxxxxxxxxxxxxxxxx
Step 4: Start Using Claude Code
Now you can start using Claude Code!
Launch Claude Code
claude
Use in a Specific Project
# Navigate to your project directory
cd C:\path\to\your\project
# Launch Claude Code
claude
🔧 Windows Common Issues
PowerShell Execution Policy Error
Solution:
# Run PowerShell as Administrator, then execute
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
npm Permission Error
Solution:
- Run PowerShell as Administrator
- Or configure npm's global directory to user folder
Environment Variables Not Taking Effect
Solution:
- Make sure you restarted PowerShell
- Check if environment variables are set correctly
- Try restarting your computer
🍎 macOS Installation
Step 1: Install Node.js Environment
Claude Code requires Node.js environment to run.
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 Download
- Visit https://nodejs.org/
- Download the LTS version for macOS
- Open the downloaded
.pkgfile - Follow the installer instructions to complete installation
macOS Notes
- You may need to use
sudoif encountering permission issues - First run may require permission in System Preferences
- Recommended to use Terminal or iTerm2
Verify Installation Success
After installation, open Terminal and enter the following commands:
node --version
npm --version
If version numbers are displayed, installation was successful!
Step 2: Install Claude Code
Open Terminal and run the following command:
# Install Claude Code globally
npm install -g @anthropic-ai/claude-code
If you encounter permission issues, 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 the version number is displayed, congratulations! Claude Code has been successfully installed.
Step 3: Set Environment Variables
To connect Claude Code to your relay service, you need to set two environment variables.
Method 1: Temporary Setup (Current Session)
Run the following commands in Terminal:
export ANTHROPIC_BASE_URL="https://use.codecodex.ai/api"
export ANTHROPIC_AUTH_TOKEN="your-api-key"
💡 Remember to replace "your-api-key" with the actual key created in the admin portal "API Keys" tab.
Method 2: Permanent Setup
Edit your shell configuration file (depending on your shell):
For zsh (default):
echo 'export ANTHROPIC_BASE_URL="https://use.codecodex.ai/api"' >> ~/.zshrc
echo 'export ANTHROPIC_AUTH_TOKEN="your-api-key"' >> ~/.zshrc
source ~/.zshrc
For bash:
echo 'export ANTHROPIC_BASE_URL="https://use.codecodex.ai/api"' >> ~/.bash_profile
echo 'export ANTHROPIC_AUTH_TOKEN="your-api-key"' >> ~/.bash_profile
source ~/.bash_profile
Verify Environment Variable Setup
After setting environment variables, verify with the following commands:
echo $ANTHROPIC_BASE_URL
echo $ANTHROPIC_AUTH_TOKEN
Expected Output Example:
https://use.codecodex.ai/api
cr_xxxxxxxxxxxxxxxxxx
Step 4: Start Using Claude Code
Now you can start using Claude Code!
Launch Claude Code
claude
Use in a Specific Project
# Navigate to your project directory
cd /path/to/your/project
# Launch Claude Code
claude
🔧 macOS Common Issues
Permission Error During Installation
Solution:
# Install using sudo
sudo npm install -g @anthropic-ai/claude-code
# Or modify npm permissions
sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
macOS Security Settings Blocking Execution
Solution:
- Open "System Preferences" → "Security & Privacy"
- In the "General" tab, click "Open Anyway"
- Or run in terminal:
sudo spctl --master-disable
Environment Variables Not Taking Effect
Solution:
- Ensure you modified the correct configuration file (
.zshrcor.bash_profile) - Restart the terminal application
- Check your current shell:
echo $SHELL
🐧 Linux Installation
Step 1: Install Node.js Environment
Claude Code requires Node.js environment to run.
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 the 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 require additional dependencies
- Use
sudoif encountering permission issues - Ensure your user has write permissions to npm's global directory
Verify Installation Success
After installation, open terminal and enter the following commands:
node --version
npm --version
If version numbers are displayed, installation was successful!
Step 2: Install Claude Code
Open terminal and run the following command:
# Install Claude Code globally
npm install -g @anthropic-ai/claude-code
If you encounter permission issues, 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 the version number is displayed, congratulations! Claude Code has been successfully installed.
Step 3: Set Environment Variables
To connect Claude Code to your relay service, you need to set two environment variables.
Method 1: Temporary Setup (Current Session)
Run the following commands in terminal:
export ANTHROPIC_BASE_URL="https://use.codecodex.ai/api"
export ANTHROPIC_AUTH_TOKEN="your-api-key"
💡 Remember to replace "your-api-key" with the actual key created in the admin portal "API Keys" tab.
Method 2: Permanent Setup
Edit your shell configuration file (depending on your shell):
For bash:
echo 'export ANTHROPIC_BASE_URL="https://use.codecodex.ai/api"' >> ~/.bashrc
echo 'export ANTHROPIC_AUTH_TOKEN="your-api-key"' >> ~/.bashrc
source ~/.bashrc
For zsh:
echo 'export ANTHROPIC_BASE_URL="https://use.codecodex.ai/api"' >> ~/.zshrc
echo 'export ANTHROPIC_AUTH_TOKEN="your-api-key"' >> ~/.zshrc
source ~/.zshrc
Verify Environment Variable Setup
After setting environment variables, verify with the following commands:
echo $ANTHROPIC_BASE_URL
echo $ANTHROPIC_AUTH_TOKEN
Expected Output Example:
https://use.codecodex.ai/api
cr_xxxxxxxxxxxxxxxxxx
Step 4: Start Using Claude Code
Now you can start using Claude Code!
Launch Claude Code
claude
Use in a Specific Project
# Navigate to your project directory
cd /path/to/your/project
# Launch Claude Code
claude
🔧 Linux Common Issues
Permission Error During Installation
Solution:
# Install using sudo
sudo npm install -g @anthropic-ai/claude-code
# Or configure npm's global directory to user folder
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
Missing Dependencies
Solution:
# Ubuntu/Debian
sudo apt-get install -y build-essential
# CentOS/RHEL/Fedora
sudo dnf groupinstall "Development Tools"
Environment Variables Not Taking Effect
Solution:
- Ensure you modified the correct configuration file (
.bashrcor.zshrc) - Restart the terminal
- Check your current shell:
echo $SHELL
🎉 Congratulations!
You’ve successfully installed and configured Claude Code. Now you can start enjoying the convenience of an AI programming assistant.
🚀 Next Steps
- Start Your First Project: Run
claudein your project directory - Explore Features: Try code generation, refactoring, debugging, etc.
- Join Community: Get more tips and best practices
📚 Related Resources
- Complete Guide - One-stop service guide
- Deployment Guide - Step-by-step deployment tutorial
- Carpool Service - Team subscription guide
💬 Need Help?
If you encounter any issues:
- Check the troubleshooting solutions above
- Visit GitHub Issues
- Join our Telegram Group