Claude Code · As of 2026-11-25

Claude Code on Windows: Install Methods, PATH, Environment Variables and Every Common Error Fixed

The most reliable way to install Claude Code on Windows is to run Anthropic's native installer in PowerShell, irm https://claude.ai/install.ps1 | iex, then open a new terminal window and run claude --version. As of 2026-11-25, Anthropic supports 64-bit Windows 10 1809+ and Windows Server 2019+, with four install routes (PowerShell, CMD, WinGet and npm); Git for Windows is optional. Almost every install error comes down to one of three things: the command was pasted into the wrong shell, the install folder isn't on PATH, or an environment variable was only set for the current window. This guide goes in order: pick the environment, install, configure, then fix errors.

QCode is an independent third-party API service and is not affiliated with Anthropic. Install commands and error strings follow Anthropic's documentation at code.claude.com; QCode settings follow docs.qcode.cc.

Updated 2026-11-26

Key facts

  • Official native install: PowerShell irm https://claude.ai/install.ps1 | iex; CMD curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd. No administrator rights needed.
  • The native installer puts claude.exe in %USERPROFILE%\.local\bin. It does not edit PATH for you, so if the command isn't found you add that folder to your user PATH.
  • Git for Windows is optional. With it, Claude Code's Bash tool uses Git Bash; without it, Claude Code runs commands through its PowerShell tool. WSL setups don't need Git for Windows.
  • Environment variables are either per-window or persistent. $env: (PowerShell) and set (CMD) only affect the current window; [Environment]::SetEnvironmentVariable, setx and the System settings dialog persist, and only new windows see the change.
  • To use QCode you need two variables: ANTHROPIC_BASE_URL=https://api.qcode.cc/api (no trailing /, no /v1) and ANTHROPIC_AUTH_TOKEN=cr_your_key. QCode also offers a Windows one-click install script.

Step 1: pick the right environment

Environment How to recognize it Needs Best for
PowerShell (native Windows) Prompt reads PS C:\Users\YourName> Nothing; recommended Most Windows users, .NET and front-end projects
CMD (native Windows) Prompt reads C:\Users\YourName> with no PS Nothing CMD habits or batch-based company scripts
Git Bash Window title shows MINGW64, prompt ends in $ Git for Windows Bash syntax on Windows
WSL 2 A terminal in Ubuntu or another distro WSL 2 enabled Linux toolchains, sandboxed command execution
WSL 1 Same WSL 1 enabled Only if WSL 2 isn't available

The differences that matter:

  • Sandboxing is not supported on native Windows; it is on WSL 2. If you want Claude Code's sandbox to isolate command execution, use WSL 2.
  • Inside WSL, run the Linux installer and launch claude from the WSL terminal. Don't install in PowerShell and try to run it in WSL or the other way round; they are two separate installs with separate config.
  • PowerShell vs CMD only changes which install command you run. Once installed, claude launches from either.

Step 2: install the official way

PowerShell (recommended):

irm https://claude.ai/install.ps1 | iex

CMD:

curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd

WinGet:

winget install Anthropic.ClaudeCode

npm (requires Node.js 22 or later):

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

How they differ:

Method Auto-update Notes
Native (PowerShell / CMD) Updates in the background, applied on next start Recommended; installs to %USERPROFILE%\.local\bin
WinGet Off by default; run winget upgrade Anthropic.ClaudeCode Set CLAUDE_CODE_PACKAGE_MANAGER_AUTO_UPDATE=1 to let Claude Code run the upgrade
npm Depends on whether the global folder is writable Upgrade with npm install -g @anthropic-ai/claude-code@latest, not npm update -g; don't install globally as administrator

The installer shows no download progress, so let it finish. Then open a new terminal window and run:

claude --version
claude doctor

claude --version prints something like 2.1.xxx (Claude Code). claude doctor runs read-only diagnostics: install health, settings-file validation errors, and warnings with suggested fixes.

Do you need Git for Windows?

Anthropic calls it recommended but optional. With Git for Windows installed, Claude Code's Bash tool uses Git Bash, which makes .sh scripts and tools like grep and sed work as expected. Without it, Claude Code falls back to its PowerShell tool. If Git is installed but Claude Code can't find Git Bash, set the path in %USERPROFILE%\.claude\settings.json:

{
  "env": {
    "CLAUDE_CODE_GIT_BASH_PATH": "C:\\Program Files\\Git\\bin\\bash.exe"
  }
}

Note the doubled backslashes in JSON.

Step 3: set environment variables (connect to QCode)

Many "installed but doesn't work" reports are really environment-variable problems. Remember one rule: the syntax differs by shell, and "temporary" and "persistent" are different things.

Current window only (good for a first test)

# PowerShell
$env:ANTHROPIC_BASE_URL = "https://api.qcode.cc/api"
$env:ANTHROPIC_AUTH_TOKEN = "cr_your_key"
claude
:: CMD (no spaces around =, no quotes around the value)
set ANTHROPIC_BASE_URL=https://api.qcode.cc/api
set ANTHROPIC_AUTH_TOKEN=cr_your_key
claude
# Git Bash / WSL
export ANTHROPIC_BASE_URL=https://api.qcode.cc/api
export ANTHROPIC_AUTH_TOKEN=cr_your_key
claude

Typing the PowerShell $env: form into CMD gives '$env:ANTHROPIC_BASE_URL' is not recognized as an internal or external command. Use set there instead.

Persistent (pick one)

Option 1: PowerShell, user scope

[Environment]::SetEnvironmentVariable('ANTHROPIC_BASE_URL', 'https://api.qcode.cc/api', 'User')
[Environment]::SetEnvironmentVariable('ANTHROPIC_AUTH_TOKEN', 'cr_your_key', 'User')

Option 2: setx (works in PowerShell and CMD)

setx ANTHROPIC_BASE_URL "https://api.qcode.cc/api"
setx ANTHROPIC_AUTH_TOKEN "cr_your_key"

setx does not affect the window you run it in, so open a new one. It also truncates values longer than 1024 characters, so never use setx to edit PATH; you can end up with a shortened PATH.

Option 3: the settings dialog. Search the Start menu for "Edit environment variables for your account" (no admin needed), or press Win+R and run rundll32 sysdm.cpl,EditEnvironmentVariables. Add both variables under "User variables" and click OK.

Option 4: Claude Code's own config at %USERPROFILE%\.claude\settings.json:

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.qcode.cc/api",
    "ANTHROPIC_AUTH_TOKEN": "cr_your_key"
  }
}

The file must be strict JSON with no // comments. If it already has settings, add env alongside them, separated by a comma.

Three common traps:

  1. Don't also set ANTHROPIC_API_KEY. QCode uses ANTHROPIC_AUTH_TOKEN only. In PowerShell, [string]::IsNullOrEmpty($env:ANTHROPIC_API_KEY) should return True. If it returns False, delete that variable and reopen the terminal.
  2. Don't keep different values in system variables and settings.json. When both exist, one overrides the other, and a stale key left in one place is a classic cause of 401. Keep a single source.
  3. No trailing / and no /v1 on the base URL. https://api.qcode.cc/api/ produces //v1/messages and .../api/v1 produces /v1/v1/messages; both return 404.

After changing persistent variables, terminals that are already open, including the integrated terminal in VS Code and other editors, won't refresh. Close them completely and reopen. WSL does not inherit your Windows user variables; export them in ~/.bashrc inside WSL.

Step 4: fix PATH problems

Symptoms: 'claude' is not recognized as an internal or external command, operable program or batch file (CMD), or claude : The term 'claude' is not recognized as the name of a cmdlet (PowerShell).

First check the program exists:

Test-Path "$env:USERPROFILE\.local\bin\claude.exe"

True means it's installed. Now check PATH:

$env:PATH -split ';' | Select-String '\.local\\bin'

No output? Add the install folder to your user PATH. This is Anthropic's documented form, and it keeps your existing PATH:

$currentPath = [Environment]::GetEnvironmentVariable('PATH', 'User')
[Environment]::SetEnvironmentVariable('PATH', "$currentPath;$env:USERPROFILE\.local\bin", 'User')

Then close every terminal and editor and reopen. Other cases:

  • More than one install. where.exe claude lists every claude on PATH. Keep one (the native install is recommended). Remove npm with npm uninstall -g @anthropic-ai/claude-code and WinGet with winget uninstall Anthropic.ClaudeCode.
  • Missing right after an update. On Windows, updates rename the old claude.exe to claude.exe.old.<timestamp> before moving the new one in. If that move fails, the folder can end up with no claude.exe. Rename the newest backup back, or rerun the installer:
Get-ChildItem "$env:USERPROFILE\.local\bin\claude.exe.old.*" | Sort-Object Name | Select-Object -Last 1 | Rename-Item -NewName claude.exe
  • claude opens the desktop app. Older Claude Desktop versions register a Claude.exe under WindowsApps that takes priority on PATH. Update Claude Desktop to the latest version.

Step 5: execution policy ("running scripts is disabled")

After an npm install, running npm or claude can fail with:

npm : File C:\Program Files\nodejs\npm.ps1 cannot be loaded because running scripts is disabled on this system.

PowerShell's execution policy is blocking the .ps1 launchers that npm creates. Three fixes:

  1. Allow local scripts for your user: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
  2. Use the .cmd launchers: npm.cmd and claude.cmd aren't covered by the policy.
  3. Use the native PowerShell installer instead. It installs a binary, not a .ps1 script.

On a company machine where IT sets the execution policy through Group Policy, ask IT rather than trying to work around the company's security settings.

Error lookup table

Error Cause Fix
'irm' is not recognized as an internal or external command PowerShell command run in CMD Open PowerShell, or use the CMD install command
The token '&&' is not a valid statement separator CMD command run in Windows PowerShell Use irm https://claude.ai/install.ps1 \| iex
A parameter cannot be found that matches parameter name 'fsSL' macOS/Linux curl ... \| bash run in PowerShell, where curl aliases Invoke-WebRequest Use the PowerShell installer
CMD prints script text and installs nothing -o install.cmd was left out Rerun the complete command
Could not create SSL/TLS secure channel TLS 1.2 not enabled in Windows PowerShell 5.1, or a TLS-inspecting company proxy Run [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 first; ask IT to add the proxy CA to the Windows store
CRYPT_E_NO_REVOCATION_CHECK / CRYPT_E_REVOCATION_OFFLINE Network blocks certificate revocation lookups (common behind company firewalls) Add --ssl-revoke-best-effort to the curl in the CMD command, or use the PowerShell installer
< was unexpected at this time / System.Xml.XmlDocument The download returned a web page, not the script Check network and proxy settings and retry, or install with WinGet
The process cannot access the file ... being used by another process Earlier install still running or antivirus scanning Close other installer windows, delete %USERPROFILE%\.claude\downloads, retry
Claude Code does not support 32-bit Windows You opened "Windows PowerShell (x86)" Open Windows PowerShell without the x86 suffix
Claude Code on Windows requires either Git for Windows (for bash) or PowerShell Neither Git Bash nor PowerShell found on PATH Add C:\Windows\System32\WindowsPowerShell\v1.0\ back to PATH, or install PowerShell 7 or Git for Windows
Error: claude native binary not installed npm skipped optional dependencies Allow optional dependencies and reinstall
cannot execute binary file: Exec format error in WSL Known WSL 1 issue In PowerShell run wsl --set-version <DistroName> 2
exec: node: not found in WSL WSL is using Windows Node.js (paths start with /mnt/c/) Install Linux Node inside WSL via your package manager or nvm, or use the native installer
API Error: 401 Wrong or expired key, or a leftover ANTHROPIC_API_KEY Re-copy the full cr_ key; remove the extra variable
404 / Invalid URL (POST /v1/v1/messages) Base URL has /v1 or a trailing / Use https://api.qcode.cc/api

Garbled text when editing older files saved in a legacy code page (for example GBK) is a runtime issue rather than an install one; see our non-UTF-8 files guide.

The shortcut: QCode's Windows one-click script

If you'd rather not do the steps above by hand, QCode publishes a Windows one-click script. In PowerShell:

irm https://qcode.cc/install/claude-code.ps1 | iex

From CMD, or if irm isn't recognized:

powershell -NoProfile -ExecutionPolicy Bypass -Command "irm https://qcode.cc/install/claude-code.ps1 | iex"

Per QCode's docs, the script runs five steps: it tests latency to the api, asia and us endpoints and lets you choose; it asks for your cr_ key (masked, with surrounding quotes and spaces stripped); it writes ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN and related variables as user-level environment variables, backing up old values to %USERPROFILE%\.qcode\; if Claude Code is missing it installs it via npm (installing Node.js LTS with winget if needed, the only step that may show a UAC prompt); and it sends one minimal test request to verify the connection.

Useful flags: -DryRun previews without changing anything, -Domain asia skips the latency test, -NoInstall writes config only, and -Uninstall removes what the script wrote. Afterwards, open a new window and run claude; "API Usage Billing" on the main screen means key-based billing is active.

FAQ

Do I need Git installed to run Claude Code on Windows?

No. Git for Windows is optional. With it, Claude Code uses Git Bash for its Bash tool; without it, Claude Code uses its PowerShell tool. Inside WSL you don't need Git for Windows at all.

The install finished but Windows says 'claude' is not recognized. What now?

Open a new terminal first, because old windows don't pick up PATH changes. If it still fails, confirm the file with Test-Path "$env:USERPROFILE\.local\bin\claude.exe", add %USERPROFILE%\.local\bin to your user PATH, and restart every terminal and editor.

Why do variables set with $env: disappear when I close PowerShell?

$env: changes only the current PowerShell process. To keep a variable, use [Environment]::SetEnvironmentVariable(..., 'User'), setx, or the "Edit environment variables for your account" dialog, then open a new window.

What's the difference between setx and [Environment]::SetEnvironmentVariable?

Both write persistent user variables that only new windows see. setx works in CMD and PowerShell but truncates values over 1024 characters, so it's a poor choice for PATH. Use [Environment]::SetEnvironmentVariable in PowerShell for PATH edits.

Should I use native Windows or WSL?

Use native Windows if your project and toolchain live on Windows (.NET, Windows Node). Use WSL 2 if you need a Linux toolchain or sandboxing. They're separate installs, and each needs its own environment variables.

How do I fix "running scripts is disabled on this system"?

PowerShell's execution policy is blocking npm's .ps1 launchers. Run Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser, call npm.cmd / claude.cmd instead, or switch to the native installer.

I get 401 or 404 after configuring QCode. What's wrong?

A 401 is usually a wrong key or a leftover ANTHROPIC_API_KEY; re-copy the full cr_ key and remove the extra variable. A 404 usually means a trailing / or /v1 on the base URL; it should be exactly https://api.qcode.cc/api.

Get it working on the Starter plan

Once Claude Code is installed, the lowest-cost way to test the whole setup is QCode's Starter plan: from $9 for 30 days with $5 of API usage per day, one key for Claude (Anthropic protocol) and GPT (OpenAI protocol), billed at official price ×1.0. For occasional use, a /pay-as-you-go pack (valid 7 days) also works. See /pricing for all tiers and current prices.

Get it working on the Starter plan

One key for both the Anthropic Messages API and OpenAI-compatible APIs. Claude and GPT are billed at the official price ×1.0; live rates are on /models.

Not sure where to start?

Try it for a week

Small Pack: $4 for $30 of quota, valid 7 days

Use it every day

Starter: $9.00/month with $5 of quota every day — just $0.060 per $1 of quota, vs about $0.113 for the Medium Pack