How to Install Claude Code - Complete Installation Guide 2025

Complete installation guide for Claude Code. Learn how to install Claude Code using the official installer, Homebrew, WinGet, or npm install @anthropic-ai/claude-code. Step-by-step setup instructions for all platforms.

ClaudeCode Guide Team
installationnpmsetupclaude-codeanthropic-aihomebrewwinget

Looking to install Claude Code? This comprehensive guide covers all installation methods, from the recommended native binary to npm. Whether you're searching for "npm install anthropic-ai claude code" or "claude code npm install", you'll find the complete installation instructions here.

The fastest and most stable way to install Claude Code is using the official installer script:

macOS / Linux:

curl -fsSL https://claude.ai/install.sh | bash

Windows (PowerShell):

irm https://claude.ai/install.ps1 | iex

That's it! Run claude in your terminal to start.

All Installation Methods

Anthropic recommends the native binary installation. This method avoids package manager conflicts and is the most stable.

macOS / Linux:

curl -fsSL https://claude.ai/install.sh | bash

Windows (PowerShell as Administrator):

irm https://claude.ai/install.ps1 | iex

Method 2: Homebrew (macOS)

For macOS users who prefer Homebrew:

brew install claude-code

Update with:

brew upgrade claude-code

Method 3: WinGet (Windows)

For Windows users:

winget install Anthropic.ClaudeCode

Update with:

winget upgrade Anthropic.ClaudeCode

Method 4: npm (Legacy)

Note: Installation via npm is now deprecated. Use the native binary method above for best results.

If you still prefer npm:

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

Important: Do NOT use sudo npm install -g as this can lead to permission issues and security risks.

What this command does:

  • npm install - Uses npm package manager to install
  • -g - Installs globally so you can use claude from any directory
  • @anthropic-ai/claude-code - The official Claude Code package from Anthropic

Method 5: yarn (Legacy)

yarn global add @anthropic-ai/claude-code

Method 6: npx (No Installation)

Run Claude Code without installing globally:

npx @anthropic-ai/claude-code

This is useful for one-time use or testing before installing.

Verify Installation

After installation, verify Claude Code is working:

claude --version

For a complete installation check:

claude doctor

This command checks your installation type, version, and configuration.

Authentication Options

Claude Code offers two authentication methods:

If you have a Claude Pro or Max subscription, you can use Claude Code with your existing account:

claude login

This opens a browser window for authentication. Your subscription includes both Claude Code and Claude on the web.

Benefits:

  • Unified subscription management
  • No separate API billing
  • Same account for web and CLI

Option 2: Anthropic API Key

For API usage billing, set up an API key:

Environment Variable (Recommended):

Add to your shell configuration (~/.bashrc, ~/.zshrc, or ~/.bash_profile):

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

Reload your shell:

source ~/.bashrc  # or ~/.zshrc

Or use the login command:

claude login --api-key

Start Using Claude Code

Once installed and authenticated:

claude

You'll enter an interactive session where you can:

  • Ask questions about code
  • Generate new code
  • Debug issues
  • Refactor existing code
  • Run commands and manage files
  • Use checkpoints to undo changes

Platform-Specific Instructions

macOS

Recommended: Native binary or Homebrew

# Option 1: Native binary
curl -fsSL https://claude.ai/install.sh | bash

# Option 2: Homebrew
brew install claude-code

Windows

Recommended: Native binary or WinGet

# Option 1: Native binary (PowerShell as Admin)
irm https://claude.ai/install.ps1 | iex

# Option 2: WinGet
winget install Anthropic.ClaudeCode

For Windows Subsystem for Linux (WSL), use the Linux instructions.

Linux

Recommended: Native binary

curl -fsSL https://claude.ai/install.sh | bash

Works on all major distributions including Ubuntu, Debian, Fedora, and Arch.

Common Installation Issues

Issue: "Permission denied" on macOS/Linux

Solution: The native installer handles permissions automatically. If using npm:

# Fix npm permissions (recommended over sudo)
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
npm install -g @anthropic-ai/claude-code

Issue: "claude: command not found" after installation

Solution: Restart your terminal, or add to PATH:

# For native installation, the script adds this automatically
# For npm, ensure global bin is in PATH:
export PATH="$(npm config get prefix)/bin:$PATH"

Issue: SSL/Network errors

Solution: Check your internet connection and firewall settings. Corporate networks may require proxy configuration.

Issue: Old version of Node.js (npm method)

Solution: Update Node.js or use the native binary instead:

# Using nvm to update Node.js
nvm install --lts
nvm use --lts

Updating Claude Code

Update method depends on how you installed:

Native binary:

curl -fsSL https://claude.ai/install.sh | bash

Homebrew:

brew upgrade claude-code

WinGet:

winget upgrade Anthropic.ClaudeCode

npm (legacy):

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

Uninstalling Claude Code

Native binary:

rm -rf ~/.claude
# Remove from PATH in your shell config

Homebrew:

brew uninstall claude-code

WinGet:

winget uninstall Anthropic.ClaudeCode

npm:

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

IDE Integration

Claude Code also offers IDE extensions:

VS Code Extension

Search for "Claude Code" in the VS Code marketplace, or:

code --install-extension anthropic.claude-code

JetBrains IDEs

Claude Code supports IntelliJ IDEA, WebStorm, PyCharm, and other JetBrains IDEs through the official plugin.

Next Steps

Now that Claude Code is installed:

  1. Getting Started Guide - Learn the basics
  2. Best Practices - Pro tips and patterns
  3. MCP Integration - Connect external tools
  4. Checkpoints & Rollback - Undo and rewind features

FAQ

Is Claude Code free?

Claude Code is free to install. You need either:

  • A Claude Pro/Max subscription (recommended), or
  • Pay-per-use via Anthropic API

What's the difference between native binary and npm installation?

The native binary is recommended because:

  • More stable and faster
  • Avoids Node.js version conflicts
  • Simpler installation process
  • Official support priority

What's the difference between claude-code and @anthropic-ai/claude-code?

@anthropic-ai/claude-code is the official npm package. The native binary is now preferred over npm installation.

Can I use Claude Code offline?

No, Claude Code requires an internet connection to communicate with Claude's API.

Which Claude model does it use?

By default, Claude Code uses Claude Sonnet. You can configure it to use Claude Opus or other models.

How do I check my installation type?

Run claude doctor to see your installation type, version, and configuration status.


Need help? Check the official documentation, join our Discord community, or report issues on GitHub.

Sources: