Step 1: Install Node.js
Method 1: Install with Homebrew (Recommended)
bash
brew install nodeIf Homebrew is not installed, install it first:
bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"Method 2: Download from official site
- Visit https://nodejs.org
- Download and install the LTS .pkg file
TIP
Verify installation
bash
node --version
npm --versionStep 2: Install Claude Code
bash
npm install -g @anthropic-ai/claude-codeTIP
Verify Claude Code installation
bash
claude --versionStep 3: Set environment variables
Determine your shell type
bash
echo $SHELLmacOS Catalina and later use zsh by default.
Method 1: Temporary (current session)
bash
export ANTHROPIC_BASE_URL="https://api.bsf.ai"
export ANTHROPIC_AUTH_TOKEN="your_api_key"Method 2: zsh permanent (Recommended)
bash
echo '' >> ~/.zshrc
echo '# API config' >> ~/.zshrc
echo 'export ANTHROPIC_BASE_URL="https://api.bsf.ai"' >> ~/.zshrc
echo 'export ANTHROPIC_AUTH_TOKEN="your_api_key"' >> ~/.zshrc
source ~/.zshrcMethod 3: bash permanent
bash
echo 'export ANTHROPIC_BASE_URL="https://api.bsf.ai"' >> ~/.bash_profile
echo 'export ANTHROPIC_AUTH_TOKEN="your_api_key"' >> ~/.bash_profile
source ~/.bash_profileMethod 4: Config File (Recommended)
Edit config file vim ~/.claude/settings.json
json{ "env": { "ANTHROPIC_AUTH_TOKEN": "Replace with your API Key", "ANTHROPIC_BASE_URL": "https://api.bsf.ai", "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": 1 }, "permissions": { "allow": [], "deny": [] } }
TIP
Verify environment variables
bash
echo $ANTHROPIC_BASE_URL
echo $ANTHROPIC_AUTH_TOKENStep 4: Start using
Launch Claude Code
bash
claudeUse in a specific project
bash
cd ~/Projects/my-project
claudeFAQ
Issue: Security blocking execution
- Open System Preferences > Privacy & Security
- Find the blocked app and click Open Anyway
Issue: npm permission error (EACCES)
When encountering EACCES errors, fix npm permissions:
bash
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.zshrc
source ~/.zshrc
npm install -g @anthropic-ai/claude-code