Claude Code on Windows: Native Install or WSL? 6-Step WSL Setup
There are two ways to run Claude Code on Windows: install it natively, or install it inside WSL (Windows Subsystem for Linux). If your project already runs on a Linux toolchain (shell scripts, Docker, Linux builds of dependencies), pick WSL. If you only write frontend code or ordinary scripts and want one less layer, try the native install first. Below, we cover the differences and then walk through a from-scratch WSL setup.
This article does not replace the official docs. Install commands, system requirements, and environment variable names change between versions, so check the Claude Code install page in Anthropic's documentation before you start.
What is the difference between native Windows and WSL?
| Native Windows | WSL | |
|---|---|---|
| Runs on | Directly on Windows | Inside a Linux distribution in WSL |
| Shell | Needs Git Bash from Git for Windows; check the official docs for exact requirements | The distribution's own bash |
| File paths | C:\Users\... | /home/username/...; Windows drives are under /mnt/c/ |
| Best for | Projects built mainly on Windows tooling | Projects that depend on Linux tools, scripts, or containers |
| Main headaches | Git Bash not found, backslashes in paths | Slow cross-filesystem access, environment variables not shared between the two sides |
A few notes:
- With a native install, Claude Code needs to find Git Bash. If Git is installed but you still get a "not found" error, the official docs describe an environment variable for pointing to the bash path. Check the docs for its name and usage.
- Claude Code in WSL is a separate installation. It reads
~/.claudeinside Linux, which is not shared with your Windows-side configuration. - You can have both, but configuration, login state, and session history are kept separately. Don't expect them to sync.
Which one should I choose?
Three questions will settle it:
- Does the project need to build or run on Linux? If so, choose WSL.
- Can your work machine enable WSL or virtualization? If not, native install is your only option.
- Are you comfortable working in a Windows terminal? If so, start native and move to WSL if you hit path or tooling problems.
How do I set up Claude Code in WSL from scratch?
Step 1: Enable WSL and install a distribution
Open PowerShell as administrator:
wsl --install
On recent Windows 10/11 builds, this enables the required components and installs the default distribution (usually Ubuntu). Restart when prompted. After the restart, a Linux terminal opens and asks you to set a username and password. If the command isn't available, your Windows version is too old; follow Microsoft's documentation to update first.
Step 2: Confirm you are on WSL 2
wsl -l -v
The VERSION column should show 2. If it shows 1, you can convert with wsl --set-version <distro-name> 2; check Microsoft's docs for details.
Step 3: Install Node.js in WSL
Installing with npm requires Node.js; check the official docs for the required version. We don't recommend the version from apt, which may be very old. nvm is easier.
Install nvm following the instructions on the nvm project page, reopen your terminal, then run:
nvm install --lts
node -v
Afterward, run which node to check. The path should be inside Linux (for example ~/.nvm/...), not /mnt/c/.... If it points to a Windows node, your Windows PATH has leaked into WSL, which causes all kinds of odd problems.
Step 4: Install Claude Code
npm install -g @anthropic-ai/claude-code
claude --version
The official docs also offer an install method that doesn't depend on npm; check them to see whether it suits your distribution. For the full install flow on all three operating systems, see Installing Claude Code (macOS / Linux / Windows).
Step 5: Keep your project in the Linux filesystem
This is the step people most often skip. Put your code under ~/projects/xxx, not under /mnt/c/Users/.... Cross-filesystem reads and writes are usually noticeably slower in WSL 2, and file watching and git status checks are more likely to misbehave.
If you need to open the folder in a Windows app, run this in the project directory:
explorer.exe .
VS Code users can install the WSL extension and run code . from the WSL terminal.
Step 6: Log in and run it for the first time
cd ~/projects/your-repo
claude
Follow the prompts to log in. If the terminal can't open a browser automatically, it will usually print a link; copy it into your Windows browser to finish. For how to phrase your first request and review what it changed, continue with How to use Claude Code: from install to your first code change.
How do I fix common problems?
Environment variables aren't visible in WSL. Variables set through the Windows GUI or setx don't automatically appear in WSL. Set them in WSL by adding them to ~/.bashrc or ~/.zshrc, then run source on the file. For the Windows side, see How to set an environment variable to store an API key on Windows.
Where config lives and what overrides what. User-level config in WSL is under ~/.claude/ in Linux; project-level config is inside the repository. For layers and precedence, see Claude Code settings.json: layers, precedence, and env configuration.
Paths written in Windows format. Inside WSL, refer to files with /mnt/c/... or Linux paths. Don't paste C:\....
Line endings break scripts. Git on the Windows side may convert files to CRLF, which causes strange errors when you run shell scripts in WSL. Check git config core.autocrlf and the repository's .gitattributes.
Commands are slow or can't connect. First rule out a server-side problem: check Claude Code availability and Anthropic API status. If status is normal, check your network and proxy settings. WSL networking sometimes doesn't inherit the Windows proxy configuration and needs its own; check Microsoft's and the official docs for details.
What if I don't have a Claude account or an overseas payment method?
Claude Code's official login relies on an Anthropic account and is subject to Anthropic's supported regions and terms of service. Check the official statements, and follow your local laws and regulations.
If you just want to use Claude Code for coding on Windows/WSL, another approach is to connect through a compatible endpoint on a third-party gateway instead of an account login. For the idea, see Can you use Claude Code without a Claude account?
AGI Plan is a commercial partner of cdnping. AGI Plan is a multi-provider LLM aggregation gateway: monthly subscription, payment in RMB, no overseas credit card needed, and compatible with both the OpenAI and Anthropic API formats. Tools like Claude Code and Codex only need one endpoint URL changed, and you can switch between multiple capability groups on the same quota. The service states plainly that it is not an officially authorized channel, and some models are available only outside mainland China; see https://agiplan.dev/models for the current list. For registering, creating a key, and editing your configuration, see the AGI Plan setup guide.
Setup checklist
wsl -l -vshows VERSION 2which nodeandwhich claudeboth resolve to paths inside Linux- The project is under
~/, not/mnt/c/ claude --versionprints a version number- Running
claudein the project directory opens the interactive interface and completes login or endpoint configuration - Environment variables are set in WSL's shell config
Next step: once all of these pass, have it make a small change in a small repository to confirm it can read and write files and run commands, then move on to your real project. If you want to estimate usage and cost first, see How to estimate Claude Code token consumption.