Getting StartedClaude CodeInstallationmacOS

macOS Installation Guide

Follow this tutorial to easily install and use Claude Code on macOS.

We offer two installation methods:

Use our one-click installation script to quickly complete all configuration.

Run the Installation Script

Open Terminal and execute the following command:

curl -fsSL https://academy.claude-code.club/assets/getting-started/installation/claude-code-installation-by-cc-club.sh | bash

The script will automatically perform the following actions:

  • Detect and install Homebrew (if not installed)
  • Detect and install Node.js (if not installed)
  • Install Claude Code
  • Configure environment variables and shell profile
⚠️

Important: You will need to enter your ANTHROPIC_AUTH_TOKEN (API key) during installation, so have it ready in advance.

⚠️

Note: The tutorial is not over yet, the tutorial is not over yet, the tutorial is not over yet — you must complete the “Next Step”: Verify and Use.

Method 2: Manual Installation

If you prefer full control over the installation process, follow the steps below to install manually.

1. Install Node.js

Claude Code requires a Node.js environment to run.

macOS Installation Methods

Method 1: Using Homebrew (Recommended)

If you already have Homebrew installed, using it to install Node.js is more convenient:

# Update Homebrew
brew update
 
# Install Node.js
brew install node

Method 2: Download from the official website

  1. Visit https://nodejs.org/
  2. Download the LTS version for macOS
  3. Open the downloaded .pkg file
  4. Follow the installer prompts to complete the installation
⚠️

macOS Notes

  • If you encounter permission issues, you may need to use sudo
  • The first run may require granting permission in System Preferences
  • It is recommended to use Terminal or iTerm2

Verify the Installation

After installation, open Terminal and enter the following commands:

node --version
npm --version

If version numbers are displayed, the installation was successful!

2. Install Claude Code

Install Claude Code

Open Terminal and run the following command:

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

If you encounter permission issues, you can use sudo:

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

Verify the Claude Code Installation

After installation, enter the following command to check if it was installed successfully:

claude --version

If a 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.

Run the following commands in Terminal to set permanent environment variables (execute one at a time):

# For zsh (default)
echo 'export ANTHROPIC_BASE_URL="https://claude-code.club/api"' >> ~/.zshrc
echo 'export ANTHROPIC_AUTH_TOKEN="your-api-key"' >> ~/.zshrc
echo 'export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1' >> ~/.zshrc
source ~/.zshrc
 
# For bash
echo 'export ANTHROPIC_BASE_URL="https://claude-code.club/api"' >> ~/.bash_profile
echo 'export ANTHROPIC_AUTH_TOKEN="your-api-key"' >> ~/.bash_profile
echo 'export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1' >> ~/.bash_profile
source ~/.bash_profile
⚠️

Remember to replace “your-api-key” with the actual key you created in the “API Keys” tab above. You need to reopen the Terminal window for the changes to take effect.

About CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC

This environment variable disables non-essential network requests from Claude Code (such as telemetry reporting). When set to 1:

  • Disables anonymous usage statistics and telemetry reporting
  • Avoids connection timeouts or slowdowns caused by inability to reach telemetry servers (such as sentry.io, statsig.com, etc.)
  • Does not affect the core functionality of Claude Code — it only disables background data collection

All users in China are recommended to configure this option, as it can significantly improve the experience.

After setting, use the following commands to verify the environment variables were set successfully:

echo $ANTHROPIC_BASE_URL
echo $ANTHROPIC_AUTH_TOKEN
echo $CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC

VSCode Claude Extension Configuration

If you use the Claude extension for VSCode, you need to configure the settings file:

Config file location: ~/.claude/config.json

If the file does not exist, create it manually.

{
  "primaryApiKey": "crs"
}

Verify the config file was set correctly:

cat ~/.claude/config.json

Verify and Use

Verify the Installation

⚠️

Important: You must close Terminal and reopen it!

After installation is complete, reopen Terminal or run source ~/.zshrc, then execute:

claude --version

If a version number is displayed, the installation was successful!

Start Using Claude Code

Now you can start using Claude Code!

Launch Claude Code

claude

Use in a Specific Project

# Navigate to your project directory
cd /path/to/your/project
 
# Launch Claude Code
claude

🎉 Congratulations! You have successfully installed and configured Claude Code. You can now start enjoying the convenience of an AI coding assistant.

Next Steps

macOS FAQ

Permission Error During Installation

Use the sudo command for installation.

macOS Security Settings Blocking Execution

Allow execution in System Preferences → Security & Privacy.

Environment Variables Not Taking Effect

Confirm that you modified the correct configuration file (zsh or bash) and reloaded the configuration file.

Need Help?

If you run into any tricky installation issues, scan the QR code below to join the Claude Code Club community group. There you can:

  • Exchange AI programming experience and get answers from 3000+ excellent developers
  • Get the latest Claude Code tips and tricks

MIT 2026 © Nextra.
加入社群CC Club返回官网