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)
node --version # Need v18+npm --version # Need v8+git --version # OptionalQuick Start (All Platforms)
If you already have Node.js installed:
npm install -g @anthropic-ai/claude-codeclaude --versionclaudeBut 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
wsl --installwsl --install -d UbuntuAfter running this command, restart your computer.
Step 2: Setup in WSL Terminal
After restart, open WSL terminal and run:
# Update systemsudo apt update && sudo apt upgrade -y
# Install dependenciessudo apt install -y curl wget git build-essential
# Install Node.js 20.xcurl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -sudo apt-get install -y nodejs
# Install Claude Codenpm install -g @anthropic-ai/claude-code
# Verifyclaude --versionmacOS Installation
macOS users have two options: Homebrew or direct Node.js installation.
Option 1: Homebrew (Recommended)
# Install Homebrew if needed/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install Node.jsbrew install node@20
# Install Claude Codenpm install -g @anthropic-ai/claude-codeOption 2: Direct Node.js
Download Node.js from nodejs.org, then:
npm install -g @anthropic-ai/claude-codeLinux Installation
Different Linux distributions have different package managers.
Ubuntu/Debian
sudo apt updatecurl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -sudo apt-get install -y nodejsnpm install -g @anthropic-ai/claude-codeCentOS/RHEL/Fedora
curl -fsSL https://rpm.nodesource.com/setup_20.x | sudo bash -sudo yum install nodejsnpm install -g @anthropic-ai/claude-codeArch Linux
sudo pacman -S nodejs npmnpm install -g @anthropic-ai/claude-codeChina Users: npm Mirror
If you are in China and experience slow downloads, use the npm mirror:
npm config set registry https://registry.npmmirror.comnpm install -g @anthropic-ai/claude-code --registry=https://registry.npmmirror.comAuthentication
After installation, authenticate with:
claude initThis 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:
- Windows users must install WSL first
- Use Node.js v20 LTS for best compatibility
- Install globally with
npm install -g - 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:
- π¨βπ» Claude Code Official Site
- π¨βπ» Node.js Downloads
Oh, and if you found these resources useful, donβt forget to support me by starring the repo on GitHub!
Comments