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:
- Press Win + X combination
- Select "Windows PowerShell" or "Terminal" from the menu
- Or: Press Win key, type "PowerShell", then press Enter
Run the following command in PowerShell:
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
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:
- Download the cc-switch tool from GitHub
- Open the tool and enter your API key as prompted
- 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
Manual Installation: Install Node.js Environment
Claude Code requires Node.js environment to run.
Method 1: Official Website Download (Recommended)
- Open your browser and visit Node.js Download Page
- Click "LTS" version to download (Long Term Support version recommended)
- After download, double-click the
.msifile - 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:
choco install nodejs
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:
node --version
npm --version
Manual Installation: Install Claude Code
Install Claude Code using npm
After opening PowerShell or CMD, run the following command:
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:
-
Open PowerShell as administrator:
- Right-click the Start menu
- Select "Windows PowerShell (Administrator)" or "Terminal (Administrator)"
-
Run the following command:
# Set execution policy
Set-ExecutionPolicy RemoteSigned -
Confirm changes:
When prompted, enter Y or A, then press Enter.
-
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-codecommand.
Verify Claude Code Installation
After installation, enter the following command to check if installation was successful:
claude --version
Note:If running claude --version shows "command Git Bash, please refer to the Git configuration solution in "Step 4" below.
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
Permanent Setup (Highly Recommended)
Run the following command in PowerShell to set user-level environment variables:
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", "https://openapi.troncode.cn",
[System.EnvironmentVariableTarget]::User)
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_AUTH_TOKEN", "your-api-key",
[System.EnvironmentVariableTarget]::User)
You need to reopen the PowerShell window for the changes to take effect.
Temporary Setup (Current session only, not recommended)
Run the following command in PowerShell:
$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
Permanent Setup (Highly Recommended)
Run the following command in CMD to set user-level environment variables:
setx ANTHROPIC_BASE_URL "https://openapi.troncode.cn"
setx ANTHROPIC_AUTH_TOKEN "your-api-key"
You need to reopen the CMD window for the changes to take effect.
Temporary Setup (Current session only, not recommended)
Run the following command in CMD:
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:
echo $env:ANTHROPIC_BASE_URL
echo $env:ANTHROPIC_AUTH_TOKEN
CMD:
echo %ANTHROPIC_BASE_URL%
echo %ANTHROPIC_AUTH_TOKEN%
Start Using Claude Code
Now you can start using Claude Code!
Launch Claude Code
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
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:
-
Download Git:
- Official download:https://git-scm.com/downloads/win
- Alternative: GitHub Mirror (Recommended for users in China)
-
Install Git:
Double-click the downloaded installer, click "Next" all the way, keep default settings.
-
Restart Claude:
After installation, reopen PowerShell or CMD and run:
# Restartclaude
✅ 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-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:
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
Manual Installation: Install Node.js Environment
Claude Code requires Node.js environment to run.
Method 1: Official Website Download (Recommended)
- Open your browser and visit Node.js Download Page
- Click "LTS" version to download (Long Term Support version recommended)
- After download, double-click the
.pkgfile - 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:
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:
node --version
npm --version
Manual Installation: Install Claude Code
Open Terminal and run the following command:
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
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:
export ANTHROPIC_BASE_URL="https://openapi.troncode.cn"
export ANTHROPIC_AUTH_TOKEN="your-api-key"
Method 2: Permanent Setup
Edit your shell configuration file:
echo 'export ANTHROPIC_BASE_URL="https://openapi.troncode.cn"' >> ~/.zshrc
echo 'export ANTHROPIC_AUTH_TOKEN="your-api-key"' >> ~/.zshrc
source ~/.zshrc
echo 'export ANTHROPIC_BASE_URL="https://openapi.troncode.cn"' >> ~/.bash_profile
echo 'export ANTHROPIC_AUTH_TOKEN="your-api-key"' >> ~/.bash_profile
source ~/.bash_profile
Start Using Claude Code
Now you can start using Claude Code!
Launch Claude Code
claude
Use in Specific Project
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:
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
Manual Installation: Install Node.js Environment
Claude Code requires Node.js environment to run.
Linux Installation Methods
Ubuntu / Debian:
sudo apt update
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejs
CentOS / RHEL / Fedora:
curl -fsSL https://rpm.nodesource.com/setup_lts.x | sudo bash -
sudo yum install nodejs
Arch Linux:
sudo pacman -S nodejs npm
Verify Installation Success
After installation, enter the following command:
node --version
npm --version
Manual Installation: Install Claude Code
Install Claude Code using npm
Open terminal, Run the following command:
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
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:
echo 'export ANTHROPIC_BASE_URL="https://openapi.troncode.cn"' >> ~/.bashrc
echo 'export ANTHROPIC_AUTH_TOKEN="your-api-key"' >> ~/.bashrc
source ~/.bashrc
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