Install Claude Code on macOS
0. Prerequisite: install Node.js
Install Node.js first (22+ recommended): Node.js on macOS
Verify: run each of these
node -vnpm -vIf you see version numbers, Node.js is installed.
1. Install Claude Code
Step 1: open Terminal (press Command + Space, type Terminal, hit Enter)
Step 2: run the install command
npm install -g @anthropic-ai/claude-codeStep 3: check the install
claude --versionIf you see a version number, it's installed.
2. Connect to Flash API
All Claude Code config lives in ~/.claude/settings.json. No environment variables to set.
2.1 Create the config directory
mkdir -p ~/.claude2.2 Write the config file (replace the API key)
cat > ~/.claude/settings.json << 'EOF'
{
"env": {
"ANTHROPIC_BASE_URL": "https://ai.flashapi.top",
"ANTHROPIC_AUTH_TOKEN": "YOUR_FLASH_API_KEY",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
}
}
EOFYou must replace YOUR_FLASH_API_KEY with the real key you copied from the Flash API console.
How:
- Copy the whole command above
- Replace
YOUR_FLASH_API_KEYwith your real key - Paste it into the terminal and run it
What the settings do:
ANTHROPIC_BASE_URL: the Flash API endpoint, without/v1ANTHROPIC_AUTH_TOKEN: your API keyCLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: turns off nonessential traffic to cut unneeded network requests
2.3 Check the file was created
cat ~/.claude/settings.jsonYou should see what you just wrote.
3. Launch and verify
Step 1: go to your project directory
cd /path/to/your/projectReplace /path/to/your/project with your actual project path.
Step 2: start Claude Code
claudeOptional: run a health check first
claude doctorTroubleshooting
1. Permission error on npm install -g
Cause: you don't have permission to install global packages.
Fix:
- Don't force it with
sudo npm install -g - Reinstall Node.js with Homebrew instead; see Node.js on macOS
- Node.js installed via Homebrew doesn't need sudo
2. claude command not found
Cause: the global npm package path isn't on your PATH.
Fix:
- Check Node.js is installed correctly:
node -v - Restart your terminal
- Still failing? Reinstall Claude Code