Install Claude Code — All Platforms Guide
TL;DR: Install with
npm install -g @anthropic-ai/claude-code, authenticate withclaude /loginor setANTHROPIC_API_KEY, and verify withclaude --version.
The Problem
You want to install Claude Code but are unsure which method works for your platform, or your installation attempt failed with errors like:
npm ERR! code EACCES
npm ERR! permission denied
Or Claude Code installed but does not start.
Why This Happens
Claude Code is distributed as an npm package that requires Node.js 18+. Installation issues typically stem from missing Node.js, incorrect npm permissions, or platform-specific PATH configuration.
The Fix
Step 1 — Install Node.js (if needed)
Claude Code requires Node.js 18 or later.
macOS:
# Using Homebrew
brew install node
# Verify version (must be 18+)
node --version
Ubuntu / Debian:
# Using NodeSource
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
node --version
Windows:
# Using winget
winget install OpenJS.NodeJS
# Or download from https://nodejs.org
WSL:
# Same as Ubuntu/Debian
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
Step 2 — Install Claude Code
# Install globally
npm install -g @anthropic-ai/claude-code
# If you get EACCES permission errors:
# Option A: Fix npm permissions
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
# Option B: Use npx (no global install)
npx @anthropic-ai/claude-code
Step 3 — Authenticate
# Interactive login (opens browser)
claude /login
# Or set API key directly (works in all environments)
export ANTHROPIC_API_KEY="sk-ant-api03-your-key-here"
Step 4 — Verify Installation
# Check version
claude --version
# Check auth status
claude auth status
# Run a quick test
echo "What is 2+2?" | claude --print
Expected output:
Claude Code v2.1.107
Authenticated as: [email protected]
4
Docker Installation
FROM node:20-slim
RUN npm install -g @anthropic-ai/claude-code
# Set API key at runtime, not in Dockerfile
ENV ANTHROPIC_API_KEY=""
ENTRYPOINT ["claude"]
# Build and run
docker build -t claude-code .
docker run -it -e ANTHROPIC_API_KEY="$ANTHROPIC_API_KEY" claude-code
VS Code Extension
- Open VS Code
- Go to Extensions (Cmd+Shift+X / Ctrl+Shift+X)
- Search “Claude Code”
- Install the official Anthropic extension
- The extension uses the CLI under the hood — ensure
claudeis on your PATH
Common Variations
| Scenario | Cause | Quick Fix |
|---|---|---|
npm ERR! EACCES |
Global npm needs root | Use ~/.npm-global prefix or npx |
command not found: claude |
Not on PATH | Add npm global bin to PATH |
| Node version too old | <18 installed | Update Node.js via nvm or package manager |
| Works in terminal, not in VS Code | VS Code uses different PATH | Add npm bin to VS Code terminal profile |
| WSL: claude starts but no output | Shell snapshot issue (v2.1.105) | Update to latest version |
Prevention
- Use nvm for Node.js management:
nvm install 20 && nvm use 20lets you switch versions without sudo. - Pin Claude Code version in CI: Use
npm install -g @anthropic-ai/[email protected]for reproducible builds.
Related Issues
- Fix Claude Code Login — Cannot Paste Auth Code — Login issues after installation
- Claude Code Docker CI/CD Pipeline Integration Guide — Full Docker configuration
- Claude Code Command Not Found After Install Troubleshooting — Browse all installation guides
Last verified: 2026-04-14. Found an issue? Open a GitHub issue.