← All guides

How to Install Claude Code — Complete Setup Guide 2026

Install Claude Code in 3 steps: npm install -g @anthropic-ai/claude-code, set ANTHROPIC_API_KEY, run claude. Covers macOS, Windows, Linux, WSL2, and common errors.

🇰🇷 한국어로 보기 →

Installing Claude Code takes under 5 minutes: run npm install -g @anthropic-ai/claude-code, set your API key, and type claude in any project directory. This guide covers every platform and the most common install errors.

Prerequisites

Requirement Version Check
Node.js 18.0+ node --version
npm 8.0+ npm --version
Anthropic API key console.anthropic.com

If you don't have Node.js yet, install it first:

# macOS (Homebrew)
brew install node

# Windows
winget install OpenJS.NodeJS

# Ubuntu/Debian
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs

Step 1: Install Claude Code

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

Verify the install:

claude --version
# claude-code/x.x.x linux-x64 node-v20.x.x

Permission error on macOS/Linux? Don't use sudo npm install -g. Instead configure a user-writable prefix: see the troubleshooting section below.

Step 2: Set Your API Key

Get a key from console.anthropic.comAPI KeysCreate Key.

# macOS/Linux — add to ~/.zshrc or ~/.bashrc
echo 'export ANTHROPIC_API_KEY="sk-ant-api03-..."' >> ~/.zshrc
source ~/.zshrc

# Windows PowerShell
[Environment]::SetEnvironmentVariable("ANTHROPIC_API_KEY", "sk-ant-api03-...", "User")

Alternatively, just run claude and it will prompt you for the key on first launch, then save it to ~/.claude/config.json.

Step 3: Run Claude Code

cd ~/your-project
claude

Expected output:

Claude Code v1.x.x
? How can I help you today?
>

Test it:

> What files are in this project?

Claude Code reads the filesystem directly — no copy-paste needed.

Platform-Specific Notes

macOS (Apple Silicon M1/M2/M3/M4)

Fully supported. No Rosetta required. If you use nvm:

nvm use 20
npm install -g @anthropic-ai/claude-code

Windows

Native Windows works via PowerShell (admin):

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

WSL2 recommended for best experience. Run inside WSL2/Ubuntu for full filesystem integration and shell tooling:

# Inside WSL2
sudo apt-get install nodejs npm
npm install -g @anthropic-ai/claude-code

Linux

# No sudo — configure npm prefix first
mkdir -p ~/.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

IDE Integration

Claude Code works in any terminal, including:

No extension installation needed — Claude Code accesses your files directly.

Initialize a Project (CLAUDE.md)

After installing, set up your first project:

cd ~/your-project
claude
/init

/init analyzes the project and creates a CLAUDE.md with your stack info, build commands, and conventions. Commit this file to share context with your whole team.

Troubleshooting

EACCES: permission denied

# Fix: configure npm to install to your home directory
mkdir -p ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.zshrc
source ~/.zshrc
npm install -g @anthropic-ai/claude-code

command not found: claude

# Check where npm installed it
npm bin -g
# Add that path to PATH in your shell config
echo 'export PATH="$(npm bin -g):$PATH"' >> ~/.zshrc
source ~/.zshrc

Authentication failed / invalid API key

# Verify the key is set
echo $ANTHROPIC_API_KEY

# Re-set if empty
export ANTHROPIC_API_KEY="sk-ant-api03-YOUR-KEY-HERE"

Node.js version too old

node --version  # Must be 18+

# Upgrade with nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
nvm install 20 && nvm use 20
npm install -g @anthropic-ai/claude-code

Corporate proxy

export HTTPS_PROXY=http://your-proxy.company.com:8080
npm install -g @anthropic-ai/claude-code

Pricing

Claude Code CLI is free. You pay only for API usage:

Model Input (per 1M tokens) Output (per 1M tokens)
Haiku 3.5 $1.00 $5.00
Sonnet 4.5 $3.00 $15.00
Opus 4.5 $15.00 $75.00

A typical developer using Claude Code 4 hours/day spends $10–25/month on Sonnet. Switch to /model haiku for repetitive tasks to cut costs by 50–70%.

New API accounts receive a small free credit (~$5) to get started.

Next Steps After Installing

  1. Run /init in your main project to create CLAUDE.md
  2. Try /help to see all available slash commands
  3. Set your default model: add CLAUDE_CODE_DEFAULT_MODEL=claude-haiku-3-5 to .env for cost savings on routine tasks
  4. Read the complete Claude Code guide for power user patterns

Frequently Asked Questions

Does Claude Code work without an internet connection?

No. Claude Code calls the Anthropic API, so an internet connection is required.

Can I use Claude Code without an Anthropic account?

No. You need an API key from console.anthropic.com. Creating an account is free.

How is Claude Code different from Claude.ai?

Claude.ai is a web/mobile chat interface. Claude Code is a terminal CLI that can read and write files in your project, run commands, and make changes across multiple files simultaneously — built specifically for software development.

Does it work on older macOS versions?

Claude Code requires Node.js 18+, which supports macOS 10.15 (Catalina) and later.

Can I install Claude Code without npm?

Not officially. npm is the only supported install method. If you can't use npm, run Claude Code via npx @anthropic-ai/claude-code without installing globally.

Is there a VS Code extension?

There is no separate VS Code extension. Claude Code runs in the terminal and integrates with any editor. The terminal inside VS Code works perfectly.


Related: Claude Code Complete Guide · Claude Code Slash Commands · Claude API Pricing 2026

P1: Claude Code Power Prompts 300 — 300 battle-tested prompts organized by use case. Get productive on day 1. View →

Tools and references