📦 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)

  1. Visit https://nodejs.org/
  2. Click to download "LTS" version (Recommended)
  3. Download Windows Installer (.msi)
  4. Run the installer, keep default settings
  5. 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):

  1. Right-click "This PC" → "Properties"
  2. Click "Advanced system settings"
  3. Click "Environment Variables"
  4. In "User variables" click "New" and add:
    • Variable name: ANTHROPIC_BASE_URL
    • Variable value: https://use.codecodex.ai/api
  5. Click "New" again and add:
    • Variable name: ANTHROPIC_AUTH_TOKEN
    • Variable value: your-api-key
  6. 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:

  1. Run PowerShell as Administrator
  2. Or configure npm's global directory to user folder
Environment Variables Not Taking Effect

Solution:

  1. Make sure you restarted PowerShell
  2. Check if environment variables are set correctly
  3. 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

  1. Visit https://nodejs.org/
  2. Download the LTS version for macOS
  3. Open the downloaded .pkg file
  4. Follow the installer instructions to complete installation

macOS Notes

  • You may need to use sudo if 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:

  1. Open "System Preferences" → "Security & Privacy"
  2. In the "General" tab, click "Open Anyway"
  3. Or run in terminal:
    sudo spctl --master-disable
Environment Variables Not Taking Effect

Solution:

  1. Ensure you modified the correct configuration file (.zshrc or .bash_profile)
  2. Restart the terminal application
  3. 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 sudo if 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:

  1. Ensure you modified the correct configuration file (.bashrc or .zshrc)
  2. Restart the terminal
  3. 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

  1. Start Your First Project: Run claude in your project directory
  2. Explore Features: Try code generation, refactoring, debugging, etc.
  3. Join Community: Get more tips and best practices

💬 Need Help?

If you encounter any issues: