Skip to main content

Installing Claude Code

This guide will walk you through installing Claude Code on your platform of choice.

Prerequisites

  • Node.js 18.0 or higher
  • npm or yarn package manager
  • An Anthropic account or API key

Platform-Specific Installation

macOS Installation

  1. Install Node.js (if not already installed):

    # Using Homebrew
    brew install node

    # Or download from nodejs.org
  2. Install Claude Code globally:

    npm install -g @anthropic-ai/claude-code
  3. Verify installation:

    claude --version
  4. Launch Claude Code:

    claude

    On first launch, Claude will guide you through connecting your Anthropic account or providing an API key.

tip

If you encounter permission errors, try using sudo or adjust your npm configuration:

npm config set prefix ~/.npm-global
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.zshrc
source ~/.zshrc

API Key Setup

Claude needs your Anthropic API key to function. You have several options for configuration:

Add to your shell profile (~/.bashrc, ~/.zshrc, etc.):

export ANTHROPIC_API_KEY="your-api-key-here"

Then reload your shell:

source ~/.bashrc  # or ~/.zshrc

Option 2: Settings File

Store in ~/.claude/settings.json:

{
"apiKey": "your-api-key-here"
}

Option 3: Interactive Setup

Simply run claude and follow the prompts to enter your API key interactively.

Troubleshooting

Permission Denied Errors

If you get EACCES errors during installation:

# Create a directory for global packages
mkdir ~/.npm-global

# Configure npm to use the new directory
npm config set prefix '~/.npm-global'

# Add to PATH (add to your shell profile)
export PATH=~/.npm-global/bin:$PATH

# Retry installation
npm install -g @anthropic-ai/claude-code

Command Not Found

If claude command is not found after installation:

  1. Check npm's global bin directory:

    npm bin -g
  2. Ensure this directory is in your PATH:

    echo $PATH
  3. Add to PATH if missing (in your shell profile):

    export PATH=$(npm bin -g):$PATH

Next Steps

Now that you have Claude Code installed, proceed to Your First Project to start using it!