Claude FastClaude Fast

Claude Code Installation: The Real Guide | Complete Setup Tutorial

Complete Claude Code installation guide with platform-specific solutions, troubleshooting, and community-tested fixes for Windows, macOS, and Linux.

Get Claude Code running in 2 minutes. Copy these commands, paste, and you're coding with AI.

Quick Start: One command gets you 90% of the way there:

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

If that worked, skip to API Setup. If not, follow your platform-specific fix below.

Requirements Before You Start

You Need:

Windows Users: You MUST use WSL2. Native Windows isn't supported.

Platform-Specific Installation

Windows (WSL2 Required)

Windows needs WSL2 first. Run these in PowerShell as Administrator:

# Install WSL2 with Ubuntu
wsl --install -d Ubuntu
# Restart when prompted
 
# Open Ubuntu terminal and run:
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
npm install -g @anthropic-ai/claude-code
claude --version

Success looks like: Version number displays without errors.

macOS (PATH Issues Common)

Standard installation often fails due to PATH conflicts:

# Try standard install first
npm install -g @anthropic-ai/claude-code
 
# If "command not found" error:
echo 'export PATH="$(npm config get prefix)/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
claude --version

Still broken? Homebrew users need this fix:

# Check where npm installed it
npm list -g @anthropic-ai/claude-code
 
# Create direct link
sudo ln -sf /opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/bin/claude /usr/local/bin/claude

Linux (Permission Fixes)

Avoid sudo requirements with user-level configuration:

# Create user npm directory
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
 
# Now install
npm install -g @anthropic-ai/claude-code
claude --version

Ubuntu/Debian specific: If you get EACCES errors, the above commands fix it.

API Key Setup

Once installation works, configure your API key:

claude
# Prompts for API key - paste it from console.anthropic.com

Where to get API key:

  1. Visit console.anthropic.com
  2. Create account or log in
  3. Go to API Keys section
  4. Create new key
  5. Copy the key (starts with sk-)

Verify Everything Works

Test your installation with this sequence:

# Check version
claude --version
 
# Run diagnostics
claude doctor
 
# Create test project
mkdir test-claude && cd test-claude
echo "console.log('Hello Claude!');" > hello.js
claude

In the Claude prompt, try: "Read hello.js and explain what it does"

Success looks like: Claude reads your file and explains the JavaScript.

Common Installation Problems

"Command Not Found"

Problem: claude command doesn't work Fix: PATH not configured properly

# Find where it installed
which claude
npm list -g @anthropic-ai/claude-code
 
# Add to PATH manually
echo 'export PATH="$PATH:/usr/local/lib/node_modules/@anthropic-ai/claude-code/bin"' >> ~/.bashrc
source ~/.bashrc

"EBADPLATFORM" Error

Problem: Trying to install on Windows without WSL2 Fix: Windows requires WSL2 - no exceptions

# In PowerShell as Administrator
wsl --install -d Ubuntu
# Restart and install in Ubuntu terminal

"EACCES" Permission Error

Problem: npm needs sudo (bad practice) Fix: Configure user-level npm directory

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

API Key Rejected

Problem: "Invalid API key" error Fix: Check key format and account status

  • Key must start with sk-
  • Check console.anthropic.com for account status
  • Create new key if needed

When Installation Completely Fails

Nuclear option - clean slate installation:

# Remove everything
npm uninstall -g @anthropic-ai/claude-code
rm -rf ~/.claude ~/.npm/_cacache
npm cache clean --force
 
# Fresh install
npm install -g @anthropic-ai/claude-code
claude --version

This fixes 95% of persistent installation problems.

Next Steps After Installation

Once claude --version and claude doctor both work:

  1. Start your first project: First Project Guide
  2. Optimize your setup: Configuration Basics
  3. Learn the fundamentals: What is Claude Code

Pro tip: Run claude doctor whenever something feels wrong. It catches most configuration issues automatically.

Installation Success Checklist

Before moving on, verify:

  • claude --version shows version number
  • claude doctor reports no errors
  • claude starts and accepts API key
  • Test project reads files correctly
  • You understand your next steps

Last updated on