DEV Community

Jenny Met
Jenny Met

Posted on

Claude Code Installation Guide for Windows: Git, PATH, Environment Variables, PowerShell, WSL, and Full Troubleshooting (2026)

Claude Code Installation Guide for Windows: Git, PATH, Environment Variables, PowerShell, WSL, and Full Troubleshooting (2026)

Windows users usually hit a different set of Claude Code problems than macOS users.

Not because Claude Code is impossible on Windows, but because Windows has more environment combinations:

  • Command Prompt
  • PowerShell
  • Windows Terminal
  • Git Bash
  • WSL
  • Node installed from MSI
  • Node installed from winget
  • Git installed but not added to PATH
  • environment variables set for one shell but not another

That is why this guide goes slower and explains the setup chain from zero.

Before You Install Anything: Choose Your Windows Path

There are two realistic paths.

Option A: Native Windows setup

Use:

  • Windows Terminal
  • PowerShell
  • Git for Windows
  • Node.js for Windows
  • npm global install

This is easier for most beginners.

Option B: WSL setup

Use:

  • WSL2
  • Ubuntu or Debian inside WSL
  • Linux install steps inside WSL

This is often cleaner for developers, but it adds an extra layer. If you are completely new, start with native Windows first unless you already use WSL.

Recommended Beginner Setup

For most new users, I recommend:

  • Windows 11 or updated Windows 10
  • Windows Terminal
  • PowerShell
  • winget for package installs
  • Git for Windows
  • Node.js LTS
  • Claude Code via npm

Step 1: Open the Right Terminal

Install or launch Windows Terminal if possible.

Then open PowerShell.

Check what shell you are in:

$PSVersionTable.PSVersion
Enter fullscreen mode Exit fullscreen mode

If PowerShell opens and works, stay there for the whole setup. Do not mix PowerShell, cmd, Git Bash, and WSL during the initial install unless you know why.

Step 2: Check Whether winget Is Available

winget is the easiest way to install Git and Node on modern Windows.

winget --version
Enter fullscreen mode Exit fullscreen mode

If it works, great.

If it does not:

  • update App Installer from Microsoft Store
  • or install packages manually from official websites

Step 3: Install Git

Check first:

git --version
Enter fullscreen mode Exit fullscreen mode

If Git is missing, install it with winget:

winget install --id Git.Git -e --source winget
Enter fullscreen mode Exit fullscreen mode

Then close and reopen PowerShell.

Verify:

git --version
where.exe git
Enter fullscreen mode Exit fullscreen mode

Why Git matters on Windows too

Same reason as on macOS:

  • repo-aware workflow
  • diffs
  • safer edits
  • version rollback
  • many developer tools assume Git

If you do not have a repo yet:

mkdir $HOME\Projects\claude-code-test -Force
cd $HOME\Projects\claude-code-test
git init
Enter fullscreen mode Exit fullscreen mode

Optional global identity:

git config --global user.name "Your Name"
git config --global user.email "you@example.com"
Enter fullscreen mode Exit fullscreen mode

Step 4: Install Node.js and npm

Check existing versions:

node --version
npm --version
Enter fullscreen mode Exit fullscreen mode

If missing, install Node.js:

winget install --id OpenJS.NodeJS.LTS -e --source winget
Enter fullscreen mode Exit fullscreen mode

Close and reopen PowerShell again.

Verify:

node --version
npm --version
where.exe node
where.exe npm
Enter fullscreen mode Exit fullscreen mode

Step 5: Install Claude Code

Check whether it already exists:

where.exe claude
claude --version
Enter fullscreen mode Exit fullscreen mode

If not, install it globally:

npm install -g @anthropic-ai/claude-code
Enter fullscreen mode Exit fullscreen mode

Then verify:

where.exe claude
claude --version
Enter fullscreen mode Exit fullscreen mode

Step 6: Fix PATH Problems on Windows

The most common Windows complaint is:

  • npm install says success
  • but claude is still not recognized

Typical error:

claude : The term 'claude' is not recognized as the name of a cmdlet, function, script file, or operable program.
Enter fullscreen mode Exit fullscreen mode

First find npm's global prefix

npm config get prefix
Enter fullscreen mode Exit fullscreen mode

Usually this points to a directory whose bin or executable location should be discoverable through PATH.

Check where npm installed claude:

npm list -g --depth=0
Enter fullscreen mode Exit fullscreen mode

Also try:

Get-Command claude -ErrorAction SilentlyContinue
Enter fullscreen mode Exit fullscreen mode

Common fix: reopen the shell

A lot of PATH issues are just stale sessions. Close PowerShell fully, open a new one, and try again.

If PATH is still wrong

Inspect the user PATH:

[Environment]::GetEnvironmentVariable("Path", "User")
Enter fullscreen mode Exit fullscreen mode

And machine PATH:

[Environment]::GetEnvironmentVariable("Path", "Machine")
Enter fullscreen mode Exit fullscreen mode

If the npm global executable location is missing, you can add it through the Windows Environment Variables UI or with PowerShell.

Be careful editing PATH programmatically. Back it up first.

Step 7: Set Environment Variables Correctly

Windows users often set variables in one place and assume every shell will see them. That is not always true.

Session-only variable in PowerShell

$env:ANTHROPIC_API_KEY = "your_key_here"
$env:OPENAI_API_KEY = "your_crazyrouter_key"
$env:OPENAI_BASE_URL = "https://crazyrouter.com/v1"
Enter fullscreen mode Exit fullscreen mode

These only last for the current session.

Persistent user-level environment variables

[Environment]::SetEnvironmentVariable("ANTHROPIC_API_KEY", "your_key_here", "User")
[Environment]::SetEnvironmentVariable("OPENAI_API_KEY", "your_crazyrouter_key", "User")
[Environment]::SetEnvironmentVariable("OPENAI_BASE_URL", "https://crazyrouter.com/v1", "User")
Enter fullscreen mode Exit fullscreen mode

Then close and reopen PowerShell.

Verify:

echo $env:ANTHROPIC_API_KEY
echo $env:OPENAI_API_KEY
echo $env:OPENAI_BASE_URL
Enter fullscreen mode Exit fullscreen mode

Step 8: Understand the Difference Between PowerShell, cmd, Git Bash, and WSL

This matters because variables and PATH can behave differently.

Environment Good for Beginners? Notes
PowerShell Yes Best native Windows choice
Command Prompt Okay Less convenient than PowerShell
Git Bash Mixed Works, but adds another shell layer
WSL Good for developers Best if you want Linux-like behavior

If you installed Claude Code in native Windows PowerShell, do not test it first in WSL and assume the same environment applies.

WSL has its own package system, paths, shell files, and variables.

Step 9: Optional WSL Path

If you want the cleanest long-term developer environment on Windows, install WSL.

Check WSL:

wsl --status
Enter fullscreen mode Exit fullscreen mode

Install if needed:

wsl --install
Enter fullscreen mode Exit fullscreen mode

Then reboot if Windows asks.

After that, open Ubuntu and treat it like a Linux machine:

  • install Git inside WSL
  • install Node inside WSL
  • install Claude Code inside WSL
  • set environment variables inside WSL shell files

Do not assume your Windows-side Node install automatically covers WSL.

Step 10: Verify Everything End-to-End

Run these checks:

git --version
node --version
npm --version
claude --version
where.exe git
where.exe node
where.exe npm
where.exe claude
Enter fullscreen mode Exit fullscreen mode

Then create a safe test folder:

mkdir $HOME\Projects\claude-code-test -Force
cd $HOME\Projects\claude-code-test
if (-not (Test-Path .git)) { git init }
"# test" | Out-File README.md -Encoding utf8
Enter fullscreen mode Exit fullscreen mode

And test the CLI with non-destructive commands first.

Common Windows Problems and Fixes

1. claude is not recognized

Cause:

  • npm global executable directory not in PATH
  • shell not restarted
  • install failed

Fix:

  • reopen PowerShell
  • check npm config get prefix
  • confirm package exists in global npm list
  • inspect PATH

2. Git installs but PowerShell still cannot find it

Cause:

  • terminal session opened before install
  • PATH not refreshed

Fix:

  • fully close and reopen terminal
  • verify with where.exe git

3. Node installs, but npm is missing or broken

Cause:

  • incomplete install
  • conflicting old Node version

Fix:

  • uninstall conflicting Node versions if necessary
  • reinstall LTS cleanly
  • verify both node --version and npm --version

4. Environment variable is set in PowerShell but not in another terminal

Cause:

  • variable was session-only

Fix:

  • use persistent user-level environment variables
  • reopen terminal after setting them

5. WSL works but PowerShell does not, or vice versa

Cause:

  • you set up two different environments

Fix:

  • decide whether you want native Windows or WSL as your main Claude Code environment
  • complete setup inside that environment fully

6. Corporate proxy blocks npm install

You may need:

npm config set proxy http://proxy.example.com:8080
npm config set https-proxy http://proxy.example.com:8080
Enter fullscreen mode Exit fullscreen mode

And possibly session variables too.

7. Antivirus or security software interferes

Sometimes security tools interfere with freshly installed CLI tools or scripts.

If install logs look normal but executables do not behave normally, test in a clean terminal, confirm the file exists, and check Windows Security or endpoint protection history.

A Safe Default Windows Setup

If you want the simplest path that is easiest to support, use this exact stack:

  • Windows Terminal
  • PowerShell
  • winget
  • Git for Windows
  • Node.js LTS
  • Claude Code via npm global install
  • persistent user environment variables

That setup is boring, and that is exactly why it is good.

FAQ

Should beginners use PowerShell or WSL for Claude Code?

If you are new, start with PowerShell. If you already prefer Linux tooling or already use WSL daily, WSL may be cleaner long term.

Why did Claude Code install successfully but still not run?

Most often: stale PATH, wrong shell, or npm installed the package into a location your current terminal is not reading.

Do I need Git before using Claude Code on Windows?

For serious use, yes. Even if the CLI starts without Git, normal coding workflows are much smoother with Git installed and configured.

Where should I store Claude Code environment variables on Windows?

For persistence, set them at the user environment level, not just the current shell session.

Is Git Bash a good place to run Claude Code?

It can work, but for beginners it adds more variables. PowerShell is simpler to document and support.

Final Take

The Windows installation story is not hard because Claude Code itself is hard. It is hard because Windows gives you many overlapping environments.

If you keep the setup consistent — PowerShell, winget, Git, Node, npm, Claude Code, then environment variables — the install becomes much easier to debug and teach.

Top comments (0)