Content is user-generated and unverified.

Complete Claude Code Installation Guide for Windows Desktop

Prerequisites

  • Windows 10 Build 19041+ or Windows 11
  • Administrator privileges
  • Internet connection
  • At least 4GB free space on target drive

Step 1: Clean Windows PATH Conflicts

1.1 Remove Conflicting Environment Variables

Open Environment Variables:

  • Press Windows + R, type sysdm.cpl, press Enter
  • Click "Environment Variables"

Clean User Variables:

  • Select "Path" in User variables → Edit
  • Remove these entries if present:
    • E:\Apps\cursor\resources\app\bin
    • E:\AppData\Roaming\nvm
    • Any paths pointing to Cursor or NVM on non-C drives

Clean System Variables:

  • Select "Path" in System variables → Edit
  • Remove the same problematic entries

Remove Individual Variables: Delete these variables if they exist (both User and System):

  • NVM_HOME
  • NVM_SYMLINK
  • Any variables pointing to E: drive development tools

1.2 Restart Computer

powershell
shutdown /r /t 0

1.3 Verify PATH Cleanup

After restart, check from Command Prompt:

cmd
echo %PATH%

Ensure no E: drive development tool paths are listed.


Step 2: Prepare Windows Desktop with WSL

2.1 Complete WSL Reset (if previously installed)

powershell
# Run as Administrator
# Stop WSL
wsl --shutdown

# Remove all distributions
wsl --unregister Ubuntu
wsl --unregister Ubuntu-20.04
wsl --unregister Ubuntu-22.04

# Disable WSL features
dism.exe /online /disable-feature /featurename:Microsoft-Windows-Subsystem-Linux /norestart
dism.exe /online /disable-feature /featurename:VirtualMachinePlatform /norestart

# Restart
shutdown /r /t 0

2.2 Fresh WSL Installation

After restart, run as Administrator:

powershell
# Re-enable WSL features
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

# Restart again
shutdown /r /t 0

After second restart:

powershell
# Set WSL2 as default
wsl --set-default-version 2

# Install Ubuntu
wsl --install -d Ubuntu

2.3 Ubuntu Initial Setup

When Ubuntu starts:

  1. Create username and password (keep simple)
  2. Update system:
bash
sudo apt update && sudo apt upgrade -y

Step 3: Move Ubuntu to Another Drive

3.1 Prepare Target Drive

powershell
# Create directory on target drive (example: E: drive)
mkdir E:\WSL\Ubuntu -Force

3.2 Export and Move Ubuntu

powershell
# Stop WSL
wsl --shutdown

# Export Ubuntu to target drive
wsl --export Ubuntu E:\WSL\ubuntu-backup.tar

# CRITICAL: Verify export succeeded before proceeding!
dir E:\WSL\ubuntu-backup.tar

⚠️ Only proceed if you see the tar file listed!

powershell
# Unregister current Ubuntu
wsl --unregister Ubuntu

# Import to new location
wsl --import Ubuntu E:\WSL\Ubuntu E:\WSL\ubuntu-backup.tar --version 2

# Set as default
wsl --set-default Ubuntu

# Verify import worked
wsl -l -v

# Clean up backup file
del E:\WSL\ubuntu-backup.tar

3.3 Fix User Account

After import, set your user as default:

powershell
# Replace 'yourusername' with your actual Ubuntu username
ubuntu config --default-user yourusername

# Test login
wsl

Step 4: Configure Ubuntu for Claude Code

4.1 Create Minimal WSL Configuration

bash
# Create clean WSL configuration
sudo nano /etc/wsl.conf

Add this content:

ini
[interop]
appendWindowsPath = false

4.2 Restart WSL to Apply Configuration

powershell
# From Windows PowerShell
wsl --shutdown
wsl

4.3 Verify Clean Environment

bash
# Check PATH is clean (no Windows paths)
echo $PATH

# Should only show Linux paths like:
# /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

4.4 Install Node.js in Ubuntu

bash
# Install Node.js from Ubuntu repository
sudo apt install -y nodejs npm

# Verify installation
node --version
npm --version

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

Step 5: Install and Test Claude Code

5.1 Install Claude Code

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

# Verify installation
claude --version

5.2 Set Up Authentication

You'll need one of these options:

Option A: Anthropic Console (API)

Option B: Claude Pro/Max Subscription

  • Subscribe to Claude Pro or Max at claude.ai
  • Use your Claude.ai account

5.3 Initialize Claude Code

bash
# Navigate to a test directory
mkdir ~/test-project
cd ~/test-project

# Start Claude Code
claude

Follow the authentication prompts to connect your account.


Step 6: Test Claude Code Configuration

6.1 Basic Functionality Test

bash
# Test basic commands
/help

# Test AI interaction
/ask "What is the current directory and what files are in it?"

# Test file generation
/generate "Create a simple hello.py file that prints 'Hello, Claude Code!'"

# Check system health
/doctor

6.2 Verify File Operations

bash
# List files created by Claude
ls -la

# Test file reading
/ask "Read the hello.py file and explain what it does"

# Test code execution (if Python installed)
python3 hello.py

Step 7: Example - Running Claude on Existing Project

7.1 Navigate to Existing Project

bash
# Option 1: WSL project (best performance)
cd ~/my-existing-project

# Option 2: Windows project (accessible but slower)
cd /mnt/c/Users/YourUsername/Documents/my-project

# Option 3: Project on moved drive
cd /mnt/e/my-projects/existing-project

7.2 Initialize Claude in Project

bash
# Start Claude Code in project directory
claude

# Generate project documentation
/generate "Create a comprehensive CLAUDE.md file that explains this project structure and how to work with it"

# Ask Claude to analyze the project
/ask "Analyze this codebase and give me a summary of what this project does"

7.3 Common Claude Code Workflows

bash
# Code analysis and review
/ask "Review the main.js file for potential improvements"

# Bug fixing
/ask "There's a bug in the login function, can you help me find and fix it?"

# Feature development
/generate "Add a new API endpoint for user profile management"

# Testing
/test "Create unit tests for the authentication module"

# Refactoring
/refactor "Convert this callback-based code to use async/await"

# Documentation
/ask "Generate JSDoc comments for all functions in utils.js"

7.4 Project-Specific Commands

bash
# Commit changes (if git is set up)
/ask "Review my changes and create an appropriate git commit message"

# Environment setup
/ask "Help me set up the development environment for this project"

# Dependencies
/ask "Analyze package.json and suggest any outdated or security-vulnerable dependencies"

Troubleshooting Common Issues

WSL PATH Errors

If you still see Windows PATH translation errors:

bash
# Add to ~/.bashrc
echo 'export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$HOME/.npm-global/bin"' >> ~/.bashrc
source ~/.bashrc

Node.js Installation Issues

bash
# Alternative Node.js installation via NodeSource
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs

Claude Code Authentication Issues

bash
# Reset authentication
/logout
# Then restart claude and re-authenticate

Performance Optimization

  • Work in WSL filesystem (~/) rather than Windows mounts (/mnt/c/) for better performance
  • Use WSL terminal instead of Windows Command Prompt for better experience
  • Consider installing Windows Terminal for better WSL integration

Best Practices

  1. Always verify exports before unregistering WSL distributions
  2. Work in WSL filesystem for better performance with Claude Code
  3. Keep WSL configuration minimal to avoid conflicts
  4. Regular backups of important WSL distributions
  5. Monitor usage costs with /cost command in Claude Code
  6. Use specific prompts for better AI assistance
  7. Keep projects organized in dedicated directories

Summary

You now have:

  • ✅ Clean Windows environment without PATH conflicts
  • ✅ WSL2 with Ubuntu on your preferred drive
  • ✅ Isolated Linux environment for development
  • ✅ Claude Code properly installed and configured
  • ✅ Ready to use Claude Code on any project

Claude Code is now ready to assist with your development workflow!

Content is user-generated and unverified.
    Complete Claude Code Installation Guide for Windows | Claude