Skip to content

How to Install Claude Code on Windows, macOS, and Linux: Step-by-Step Guide

Purpose

I want to install Claude Code, the terminal-based AI programming assistant from Anthropic. But different operating systems have different requirements.

Let me walk through the installation process for each platform.

Requirements

Before installing Claude Code, check these requirements:

  • Node.js v18+ (v20 LTS recommended)
  • npm v8+
  • Git v2.0+ (optional but recommended)
Check requirements
node --version # Need v18+
npm --version # Need v8+
git --version # Optional

Quick Start (All Platforms)

If you already have Node.js installed:

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

But on Windows, you need WSL first. Let me explain each platform.

Windows Installation

Windows requires WSL (Windows Subsystem for Linux) because Claude Code is designed with Unix philosophy and needs POSIX compatibility.

Step 1: Install WSL

Install WSL in PowerShell (Administrator)
wsl --install
wsl --install -d Ubuntu

After running this command, restart your computer.

Step 2: Setup in WSL Terminal

After restart, open WSL terminal and run:

Setup in WSL
# Update system
sudo apt update && sudo apt upgrade -y
# Install dependencies
sudo apt install -y curl wget git build-essential
# 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
npm install -g @anthropic-ai/claude-code
# Verify
claude --version

macOS Installation

macOS users have two options: Homebrew or direct Node.js installation.

Install via Homebrew
# Install Homebrew if needed
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install Node.js
brew install node@20
# Install Claude Code
npm install -g @anthropic-ai/claude-code

Option 2: Direct Node.js

Download Node.js from nodejs.org, then:

Install after Node.js download
npm install -g @anthropic-ai/claude-code

Linux Installation

Different Linux distributions have different package managers.

Ubuntu/Debian

Ubuntu/Debian installation
sudo apt update
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

CentOS/RHEL/Fedora

CentOS/RHEL/Fedora installation
curl -fsSL https://rpm.nodesource.com/setup_20.x | sudo bash -
sudo yum install nodejs
npm install -g @anthropic-ai/claude-code

Arch Linux

Arch Linux installation
sudo pacman -S nodejs npm
npm install -g @anthropic-ai/claude-code

China Users: npm Mirror

If you are in China and experience slow downloads, use the npm mirror:

Use npm mirror for China
npm config set registry https://registry.npmmirror.com
npm install -g @anthropic-ai/claude-code --registry=https://registry.npmmirror.com

Authentication

After installation, authenticate with:

Authenticate Claude Code
claude init

This opens a browser window for authentication. Follow the prompts.

Summary

In this post, I showed how to install Claude Code on all platforms. The key points are:

  1. Windows users must install WSL first
  2. Use Node.js v20 LTS for best compatibility
  3. Install globally with npm install -g
  4. China users can use npm mirror for faster downloads

After installation, run claude init to authenticate and start coding.

Final Words + More Resources

My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me

Here are also the most important links from this article along with some further resources that will help you in this scope:

Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!

Comments