Skip to main content

Set Up Claude Code with Windows PowerShell

6/42
Chapter 2 Project Setup & Introduction to Claude Code

Set Up Claude Code with Windows PowerShell

4 min read Lesson 6 / 42 Preview

Installing Claude Code on Windows

This lesson covers Claude Code installation on Windows using PowerShell, with notes on the recommended WSL2 approach for full feature support.

Option 1: Windows with PowerShell (Quick Start)

Step 1 — Install Node.js:

Download the Windows installer from nodejs.org (LTS version), or use winget:

winget install OpenJS.NodeJS.LTS

Restart PowerShell, then verify:

node --version
npm --version

Step 2 — Install Claude Code:

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

Step 3 — Authenticate:

claude
# Follow the browser login prompt

Or set the API key:

$env:ANTHROPIC_API_KEY = "sk-ant-xxxxx"
claude

To persist the API key, add it to your PowerShell profile:

notepad $PROFILE
# Add this line:
# $env:ANTHROPIC_API_KEY = "sk-ant-xxxxx"

WSL2 (Windows Subsystem for Linux) provides the best experience because Claude Code was designed for Unix-like environments. Many shell commands, scripts, and tooling work seamlessly on WSL2.

Step 1 — Install WSL2:

wsl --install
# Restart your computer
# Set up your Ubuntu username and password

Step 2 — Inside WSL2, install Node.js:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
source ~/.bashrc
nvm install 20

Step 3 — Install Claude Code:

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

From here, follow the same authentication steps as the macOS lesson.

PowerShell vs WSL2 Comparison

Feature PowerShell WSL2
Installation complexity Simple Moderate
Bash command support Limited Full
Git integration Good Excellent
Docker support Through Docker Desktop Native
File system performance Native Near-native
Claude Code compatibility Good Excellent

Accessing Your Windows Files from WSL2

Your Windows drives are mounted under /mnt/:

cd /mnt/c/Users/YourName/Projects

For better performance, store projects inside the WSL2 file system:

mkdir ~/projects && cd ~/projects

Common Windows Issues

Execution policy errors in PowerShell:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

"EACCES" permission errors: Run PowerShell as Administrator for the initial global install only.

WSL2 network issues: If Claude Code cannot reach the API, check that your DNS is configured correctly in WSL2. Create or edit /etc/resolv.conf with nameserver 8.8.8.8.

Key Takeaways

  • PowerShell works for basic Claude Code usage — quick to set up
  • WSL2 is the recommended approach for full compatibility with all shell commands
  • Install with npm install -g @anthropic-ai/claude-code on either platform
  • Store projects inside the WSL2 file system for best performance when using WSL2
  • Use wsl --install to get started with WSL2 — it installs Ubuntu by default
Previous Set Up Claude Code on Mac