Windows WSL Path Conflict Error — Fix (2026)

The Error

/mnt/c/Program Files/nodejs/node.exe: cannot execute binary file: Exec format error
$ which node
/mnt/c/Program Files/nodejs/node.exe

This error occurs in WSL when the PATH includes Windows directories, causing WSL to try running the Windows node.exe binary instead of a Linux-native node binary.

The Fix

  1. Install Node.js natively inside WSL:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
source ~/.bashrc
nvm install 22
  1. Remove Windows paths from WSL PATH:
echo '[interop]
appendWindowsPath = false' | sudo tee -a /etc/wsl.conf
  1. Restart WSL:
# In Windows PowerShell:
wsl --shutdown
  1. Reinstall Claude Code inside WSL:
npm install -g @anthropic-ai/claude-code
claude --version

Why This Happens

WSL2 by default appends Windows PATH entries to the Linux PATH. This means node, npm, and other commands resolve to their Windows .exe versions in /mnt/c/Program Files/nodejs/. These Windows binaries cannot execute in the Linux environment, causing “Exec format error.” Claude Code must run with Linux-native Node.js inside WSL.

If That Doesn’t Work

  • Manually override the PATH to prioritize WSL node:
export PATH="$HOME/.nvm/versions/node/v22.12.0/bin:$PATH"
echo 'export PATH="$HOME/.nvm/versions/node/v22.12.0/bin:$PATH"' >> ~/.bashrc
  • Verify you are running the correct binary:
file $(which node)
# Should say: ELF 64-bit LSB executable (Linux)
# Not: PE32+ executable (Windows)
  • If you need Windows interop for other tools, selectively remove only the nodejs path.

Prevention

Add this to your CLAUDE.md:

# WSL Configuration
- Set appendWindowsPath = false in /etc/wsl.conf.
- Install Node.js via nvm inside WSL, not from Windows.
- Always verify: file $(which node) shows ELF, not PE32+.

See Also

This fix also applies if you see variations of this error:

  • Connection or process errors with similar root causes in the same subsystem
  • Timeout variants where the operation starts but does not complete
  • Permission variants where access is denied to the same resource
  • Configuration variants where the same setting is missing or malformed

If your specific error message differs slightly from the one shown above, the fix is likely the same. The key indicator is the operation that failed (shown in the stack trace) rather than the exact wording of the message.

Frequently Asked Questions

Does this error affect all operating systems?

This error can occur on macOS, Linux, and Windows (WSL). The exact error message may differ slightly between platforms, but the root cause and fix are the same. macOS users may see additional Gatekeeper or notarization prompts. Linux users should check that the relevant system packages are installed. Windows users should ensure they are running inside WSL2, not native Windows.

Will this error come back after updating Claude Code?

Updates can occasionally reintroduce this error if the update changes default configurations or dependency requirements. After updating Claude Code, verify your project still builds and runs correctly. If the error returns, reapply the fix and check the changelog for breaking changes.

Can this error cause data loss?

No, this error occurs before or during an operation and does not corrupt existing files. Claude Code’s edit operations are atomic — they either complete fully or not at all. However, if the error occurs during a multi-step operation, you may have partial changes that need to be reviewed with git diff before continuing.

How do I report this error to Anthropic if the fix does not work?

Open an issue at github.com/anthropics/claude-code with: (1) the full error message including stack trace, (2) your Node.js version (node --version), (3) your Claude Code version (claude --version), (4) your operating system and version, and (5) the command or operation that triggered the error.

Quick setup → Launch your project with our Project Starter.

Try it: Paste your error into our Error Diagnostic for an instant fix.