Claude Code Complete Installation Guide | Windows/Mac/Linux

51 min read

Claude Code Complete Installation Guide

Claude Code is an AI-powered coding assistant CLI tool provided by Anthropic. This comprehensive guide covers installation methods for Windows, Mac, Linux, and all major platforms.

What is Claude Code

Claude Code is an innovative tool that allows you to code while interacting with AI directly from your terminal.

Key Features

  • Terminal Integration: Access Claude AI directly from the command line
  • Context Awareness: Automatically understands your project files
  • MCP Support: Integrates with external tools via Model Context Protocol
  • Cross-Platform: Compatible with Windows, Mac, and Linux

System Requirements

  • Node.js: v18.0.0 or higher (recommended: v20+)
  • OS: Windows 10+, macOS 11+, Linux (major distributions)
  • Memory: Minimum 4GB (recommended: 8GB+)
  • Storage: 500MB+ free space

macOS Installation

On macOS, using Homebrew is the simplest method.

Method 1: Homebrew (Recommended)

If Homebrew is already installed, run:

brew install claude-code

Verify the installation:

claude --version

Method 2: Via npm

If Node.js is installed, you can use npm:

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

Administrator privileges may be required for global installation:

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

Initial Setup

After installation, authenticate:

claude login

A browser window will open for Anthropic account authentication. Once completed, you’ll see a confirmation message in the terminal.

Windows Installation

On Windows, you can choose between npm, WSL, or native installation.

Method 1: Via npm (Recommended)

After installing Node.js, run:

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

If you encounter execution policy errors in PowerShell:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Method 2: WSL (Windows Subsystem for Linux)

Using WSL allows you to run Claude Code in a Linux environment.

Install WSL:

wsl --install

After restarting, install Claude Code within WSL:

# For Ubuntu/Debian
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

Method 3: Git Bash

If using Git Bash, you can install via npm:

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

Windows Considerations

  • PATH Configuration: Ensure npm global bin directory is in your PATH environment variable
  • Firewall: You may be prompted to allow access on first run
  • Antivirus: Add to exceptions if falsely detected

Linux Installation

Installation methods for major Linux distributions.

Ubuntu/Debian-based

Set up Node.js:

# Install Node.js 20.x
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs

Install Claude Code:

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

Fedora/RHEL/CentOS-based

# Install Node.js 20.x
curl -fsSL https://rpm.nodesource.com/setup_20.x | sudo bash -
sudo dnf install -y nodejs

# Install Claude Code
sudo npm install -g @anthropic-ai/claude-code

Arch Linux

# Using yay
yay -S nodejs npm
npm install -g @anthropic-ai/claude-code

Avoiding Permission Errors

If you encounter permission errors during global installation, change npm’s global directory:

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

Then install without sudo:

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

Detailed npm Installation

Using npm is a universal method across all platforms.

Global Installation

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

Local Installation (Per Project)

For use in specific projects only:

cd your-project
npm install @anthropic-ai/claude-code
npx claude

Version-Specific Installation

To install a specific version:

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

Updating

To update an existing installation to the latest version:

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

Or:

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

Initial Setup and Authentication

After installation, perform the initial setup.

Login

claude login

A browser will automatically open, prompting you to authenticate with your Anthropic account.

Proxy Configuration

If using a proxy in corporate networks:

export HTTPS_PROXY=http://proxy.example.com:8080
claude login

For Windows PowerShell:

$env:HTTPS_PROXY="http://proxy.example.com:8080"
claude login

Manual API Key Setup

If login doesn’t work, you can manually set the API key:

export ANTHROPIC_API_KEY=your_api_key_here

Get your API key from the Anthropic Console.

Verifying Installation

Confirm that Claude Code is correctly installed.

Check Version

claude --version

The latest version should be displayed.

Display Help

claude --help

This shows a list of available commands.

Test Run

Try Claude Code with a simple command:

claude

When the prompt appears, type:

Hello, Claude! Please tell me about yourself.

If you receive a response from Claude AI, the setup is complete.

Troubleshooting

Common issues and their solutions.

Command Not Found

Symptom: claude: command not found

Causes:

  • npm global bin directory not in PATH
  • Installation didn’t complete properly

Solutions:

# Check npm global bin path
npm config get prefix

# Add to PATH (for bash)
echo 'export PATH="$(npm config get prefix)/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

# For zsh
echo 'export PATH="$(npm config get prefix)/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

Outdated Node.js Version

Symptom: Error: Node.js version 18.0.0 or higher is required

Solution:

Update Node.js:

# macOS (Homebrew)
brew upgrade node

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

# Windows
# Download the latest version from the official Node.js website

npm Permission Errors

Symptom: EACCES: permission denied

Solution:

Change npm’s global directory:

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

Reinstall (without sudo):

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

Character Encoding Issues in WSL

Symptom: Japanese characters not displaying correctly

Solution:

Set locale:

sudo apt-get install language-pack-ja
sudo update-locale LANG=ja_JP.UTF-8

Change terminal font to one that supports Japanese characters.

Authentication Errors

Symptom: Authentication failed

Solutions:

  1. Logout and login again:
claude logout
claude login
  1. Manually set API key:
export ANTHROPIC_API_KEY=your_api_key
  1. Check proxy settings (if in proxy environment)

Update Not Reflecting

Symptom: Old version shown with claude --version

Solution:

Clear cache and reinstall:

npm cache clean --force
npm uninstall -g @anthropic-ai/claude-code
npm install -g @anthropic-ai/claude-code

Uninstallation

How to uninstall Claude Code when no longer needed.

If Installed via npm

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

If Installed via Homebrew (macOS)

brew uninstall claude-code

Removing Configuration Files

To also remove authentication and configuration files:

# macOS/Linux
rm -rf ~/.config/claude-code
rm -rf ~/.claude

# Windows
rmdir /s "%APPDATA%\claude-code"

Summary

The recommended installation methods for Claude Code by platform:

  • macOS: Homebrew (brew install claude-code)
  • Windows: npm or WSL
  • Linux: Global installation via npm

After installation, complete authentication with claude login and start using immediately. If you encounter issues, refer to the troubleshooting section in this guide.

Leverage Claude Code to build an efficient development environment!

Related Articles