One-Click Install (Recommended)

Use the one-click installation script to automatically install Node.js and Claude Code - the easiest and fastest way!

How to open PowerShell:

  1. Press Win + X combination
  2. Select "Windows PowerShell" or "Terminal" from the menu
  3. Or: Press Win key, type "PowerShell", then press Enter

Run the following command in PowerShell:

# One-click install Claude Code
curl -fsSL https://claude.ai/install.sh | bash
⚠️

Important Notes

  • This command requires access to international networks. Please ensure your network can access claude.ai
  • If you cannot access it, you may need to use a proxy tool (VPN)
  • The installation script will automatically install Node.js and Claude Code without manual dependency installation

Verify Installation

After installation, run the following command to check:

# Check version
claude --version

If the version number is displayed, congratulations! Installation successful.

Next Step: Configure Environment Variables

After installation, you need to configure environment variables to use it properly. You have two options:

Method 2: Manual Environment Variable Configuration

Please refer to "Step 3: Set Environment Variables" below for manual configuration

1

Manual Installation: Install Node.js Environment

Claude Code requires Node.js environment to run.

Windows Installation Methods Choose one, Method 1 recommended

Method 1: Official Website Download (Recommended)

  1. Open your browser and visit Node.js Download Page
  2. Click "LTS" version to download (Long Term Support version recommended)
  3. After download, double-click the .msi file
  4. Follow the installation wizard to complete installation, keep default settings

Method 2: Use Package Manager

If you have Chocolatey or Scoop installed, you can use command line installation:

# Using Chocolatey
choco install nodejs
# Or using Scoop
scoop install nodejs
ℹ️

Windows Notes

  • It's recommended to use PowerShell instead of CMD
  • If you encounter permission issues, try running as administrator
  • Some antivirus software may give false positives, you may need to add to whitelist

Verify Installation Success

After installation, open PowerShell or CMD and enter the following commands:

# Check version
node --version
npm --version

If version numbers are displayed, installation successful!

2

Manual Installation: Install Claude Code

Install Claude Code using npm

After opening PowerShell or CMD, run the following command:

# Install Claude Code globally
npm install -g @anthropic-ai/claude-code

This command will download and install the latest version of Claude Code from the official npm repository.

⚠️

Common Error: PowerShell Execution Policy Restriction

If you encounter the following error when running npm commands:

npm : Cannot loadfile D:\\Program Files\\nodejs\\npm.ps1,
because running scripts is disabled on this system.
Solution:
  1. Open PowerShell as administrator:
    • Right-click the Start menu
    • Select "Windows PowerShell (Administrator)" or "Terminal (Administrator)"
  2. Run the following command:
    # Set execution policy
    Set-ExecutionPolicy RemoteSigned
  3. Confirm changes:

    When prompted, enter Y or A, then press Enter.

  4. Re-run the installation command:

    You can close the administrator window, open a regular PowerShell window, and run again npm install -g @anthropic-ai/claude-code command.

After completion, npm commands can be used normally.

Verify Claude Code Installation

After installation, enter the following command to check if installation was successful:

# Check version
claude --version

If the version number is displayed, congratulations! Claude Code has been successfully installed.

⚠️

Note:If running claude --version shows "command Git Bash, please refer to the Git configuration solution in "Step 4" below.

3

Set Environment Variables

Configure Claude Code Environment Variables

To connect Claude Code to your relay service, you need to set two environment variables:

PowerShell Setup Method

Temporary Setup (Current session only, not recommended)

Run the following command in PowerShell:

# Set Environment Variables Temporarily
$env:ANTHROPIC_BASE_URL = "https://openapi.troncode.cn"
$env:ANTHROPIC_AUTH_TOKEN = "your-api-key"

Settings will be invalid after closing the window.

CMD Setup Method

Temporary Setup (Current session only, not recommended)

Run the following command in CMD:

# Set Environment Variables Temporarily
set ANTHROPIC_BASE_URL=https://openapi.troncode.cn
set ANTHROPIC_AUTH_TOKEN=your-api-key

Settings will be invalid after closing the window.

Remember to replace "your-api-key" with your actual key.

Verify Environment Variable Setup

After setting environment variables, you can verify with the following command:

PowerShell:
# View environment variables
echo $env:ANTHROPIC_BASE_URL
echo $env:ANTHROPIC_AUTH_TOKEN
CMD:
# View environment variables
echo %ANTHROPIC_BASE_URL%
echo %ANTHROPIC_AUTH_TOKEN%
4

Start Using Claude Code

Now you can start using Claude Code!

Launch Claude Code

# Launch command
claude

When launching claude for the first time, it will automatically configure the environment and check if all settings are correct.

Use in Specific Project

# Navigate to project directory
cd C:\path\to\your\project
# Launch Claude Code
claude

Common Notes:

If you encounter the following error when running claude command:

Claude Code on Windows requires git-bash...

Solution:

  1. Download Git:
  2. Install Git:

    Double-click the downloaded installer, click "Next" all the way, keep default settings.

  3. Restart Claude:

    After installation, reopen PowerShell or CMD and run:

    # Restart
    claude

✅ After Git is successfully installed, Claude command can run normally.

Windows Common Issues Solutions

Error "permission denied" during installation

This is usually a permission issue, try the following methods:

  • Run PowerShell as administrator
  • Or add before the original command:npm config set prefix %APPDATA%\npm

PowerShell script execution is disabled

If you encounter execution policy restrictions, run:

# Set execution policy
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Environment variables still not working after setup

After setting permanent environment variables, you need to:

  • Restart PowerShell or CMD
  • Or log out and log back into Windows
  • Verify settings:echo $env:ANTHROPIC_BASE_URL

One-Click Install (Recommended)

Use the one-click installation script to automatically install Node.js and Claude Code - the easiest and fastest way!

Open Terminal and run the following command:

# One-click install Claude Code
curl -fsSL https://claude.ai/install.sh | bash
⚠️

Important Notes

  • This command requires access to international networks. Please ensure your network can access claude.ai
  • If you cannot access it, you may need to use a proxy tool (VPN)
  • The installation script will automatically install Node.js and Claude Code without manual dependency installation

Verify Installation

After installation, run the following command to check:

# Check version
claude --version

If the version number is displayed, congratulations! Installation successful.

Configure Environment Variables

After installation, you need to configure environment variables to use it properly. You have two options:

Method 2: Manual Environment Variable Configuration

Please refer to "Step 1: Manual Install Node.js Environment" below for manual configuration

1

Manual Installation: Install Node.js Environment

Claude Code requires Node.js environment to run.

macOS Installation Methods Choose one, Method 1 recommended

Method 1: Official Website Download (Recommended)

  1. Open your browser and visit Node.js Download Page
  2. Click "LTS" version to download (Long Term Support version recommended)
  3. After download, double-click the .pkg file
  4. Follow the installation wizard to complete installation, keep default settings

Method 2: Using Homebrew

If you have Homebrew installed, you can use command line installation:

# Install using Homebrew
brew install node
ℹ️

macOS Notes

  • It's recommended to use Homebrew for installation, easier to manage versions
  • If you encounter permission issues, you may need to use sudo
  • Some versions of macOS may require installing Xcode Command Line Tools

Verify Installation Success

After installation, open terminal and enter the following command:

# Check version
node --version
npm --version

If version numbers are displayed, installation successful!

2

Manual Installation: Install Claude Code

Install Claude Code using npm

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:

# Install using 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:

# Check version
claude --version

If the version number is displayed, congratulations! Claude Code has been successfully installed.

3

Set Environment Variables

Configure Claude Code 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 command in Terminal:

# Set Environment Variables
export ANTHROPIC_BASE_URL="https://openapi.troncode.cn"
export ANTHROPIC_AUTH_TOKEN="your-api-key"
Method 2: Permanent Setup

Edit your shell configuration file:

# For zsh (default)
echo 'export ANTHROPIC_BASE_URL="https://openapi.troncode.cn"' >> ~/.zshrc
echo 'export ANTHROPIC_AUTH_TOKEN="your-api-key"' >> ~/.zshrc
source ~/.zshrc
# For bash
echo 'export ANTHROPIC_BASE_URL="https://openapi.troncode.cn"' >> ~/.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

# Launch command
claude

Use in Specific Project

# Navigate to your project directory
cd /path/to/your/project

# Launch Claude Code
claude

One-Click Install (Recommended)

Use the one-click installation script to automatically install Node.js and Claude Code - the easiest and fastest way!

Open terminal, Run the following command:

# One-click install Claude Code
curl -fsSL https://claude.ai/install.sh | bash
⚠️

Important Notes

  • This command requires access to international networks. Please ensure your network can access claude.ai
  • If you cannot access it, you may need to use a proxy tool (VPN)
  • The installation script will automatically install Node.js and Claude Code without manual dependency installation

Verify Installation

After installation, run the following command to check:

claude --version

If the version number is displayed, congratulations! Installation successful.

Next Step: Configure Environment Variables

After installation, you need to configure environment variables to use it properly. You have two options:

Method 1: Use cc-switch for Quick Configuration (Recommended)

cc-switch is a visual configuration tool that helps you quickly configure environment variables:

  1. Download the cc-switch tool from GitHub
  2. Open the tool and enter your API key as prompted
  3. Click the configure button to automatically complete environment variable setup
Method 2: Manual Environment Variable Configuration

Please refer to "Step 3: Set Environment Variables" below for manual configuration

1

Manual Installation: Install Node.js Environment

Claude Code requires Node.js environment to run.

Linux Installation Methods

Ubuntu / Debian:
# Update package manager
sudo apt update
# Install Node.js
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejs
CentOS / RHEL / Fedora:
# Install Node.js
curl -fsSL https://rpm.nodesource.com/setup_lts.x | sudo bash -
sudo yum install nodejs
Arch Linux:
# Install Node.js
sudo pacman -S nodejs npm

Verify Installation Success

After installation, enter the following command:

node --version
npm --version
2

Manual Installation: Install Claude Code

Install Claude Code using npm

Open terminal, 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

claude --version
3

Set Environment Variables

Configure Claude Code Environment Variables

Temporary Setup (Current Session)
export ANTHROPIC_BASE_URL="https://openapi.troncode.cn"
export ANTHROPIC_AUTH_TOKEN="your-api-key"
Permanent Setup

Edit your shell configuration file:

# For bash
echo 'export ANTHROPIC_BASE_URL="https://openapi.troncode.cn"' >> ~/.bashrc
echo 'export ANTHROPIC_AUTH_TOKEN="your-api-key"' >> ~/.bashrc
source ~/.bashrc
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