Installation Failure on Windows - Unsupported OS Error

Status Fixed / completed
Maintainer reply ✓ Yes — ashwin-ant
Activity 9 comments · opened Feb 27, 2025 · closed Feb 27, 2025
💡 Likely answer: A maintainer (ashwin-ant, collaborator) responded on this thread — see the highlighted reply below.

Description:

I attempted to install @anthropic-ai/claude-code on WSL using the following command:

npm install -g @anthropic-ai/claude-code --force --no-os-check

However, the installation failed with the following error message:

npm WARN using --force Recommended protections disabled.
npm WARN cleanup Failed to remove some directories [
npm WARN cleanup   [
npm WARN cleanup     'C:\\Users\\<USER>\\AppData\\Roaming\\npm\\node_modules\\@anthropic-ai\\claude-code',
npm WARN cleanup     [Error: EPERM: operation not permitted, rmdir 'C:\Users\<USER>\AppData\Roaming\npm\node_modules\@anthropic-ai\claude-code\vendor\sdk\src\internal'] {
npm WARN cleanup       errno: -4048,
npm WARN cleanup       code: 'EPERM',
npm WARN cleanup       syscall: 'rmdir',
npm WARN cleanup       path: 'C:\\Users\\<USER>\\AppData\\Roaming\\npm\\node_modules\\@anthropic-ai\\claude-code\\vendor\\sdk\\src\\internal'
npm WARN cleanup     }
npm WARN cleanup   ]
npm WARN cleanup ]
npm ERR! code 1
npm ERR! path C:\Users\<USER>\AppData\Roaming\npm\node_modules\@anthropic-ai\claude-code
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node scripts/preinstall.js
npm ERR! Error: Claude Code is not supported on Windows.
npm ERR! Claude Code requires macOS or Linux to run properly.
npm ERR! If you are using WSL (Windows Subsystem for Linux):
npm ERR!   1. Make sure you are running npm install from within the WSL terminal, not from PowerShell or CMD
npm ERR!   2. If you're still seeing this message in WSL, your environment may be incorrectly reporting as Windows
npm ERR! Please visit https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/overview#check-system-requirements for troubleshooting information.

Expected Behavior

  • The package should either install successfully or clearly state during the npm install process that it does not support Windows, before attempting installation.

Actual Behavior

  • The installation proceeds partially, attempts cleanup, then fails with an EPERM error.
  • The error message suggests running the installation in WSL, but I am already running this inside WSL on the command line.
  • The script still detects Windows incorrectly and prevents installation.

Steps to Reproduce

  1. Open a WSL terminal
  2. Run the command:
npm install -g @anthropic-ai/claude-code --force --no-os-check

System Information

OS: WSL (Ubuntu on Windows 10/11)
NPM Version: 10.2.3
WSL Version: 2.4.11.0

View original on GitHub ↗

9 Comments

xoma-zver · 1 year ago

To properly install Node.js packages in WSL that detect your environment as Linux rather than Windows:

  1. Install NVM (Node Version Manager) in WSL:

``bash
sudo apt-get install curl
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
``

  1. Close and reopen your terminal, or run:

``bash
source ~/.bashrc
``

  1. Install Node.js using NVM:

``bash
nvm install node
``

  1. Verify Node.js is installed in the Linux environment:

``bash
which npm
`
Should show:
/home/username/.nvm/versions/node/vX.X.X/bin/npm`

  1. Now install packages through this Node.js installation:

``bash
npm config set os linux
npm install -g @anthropic-ai/claude-code
``

Why This Works

This solution works because you're creating an isolated Node.js environment within WSL rather than using a Windows-installed version. The previous errors occurred because npm was likely still pointing to a Windows installation (evident from paths like C:\Users\).

NVM creates a completely isolated installation that's properly contained within the Linux filesystem. This ensures packages correctly detect the Linux environment and prevents Windows paths from appearing in npm operations.

/ using https://learn.microsoft.com/en-us/windows/dev-environment/javascript/nodejs-on-wsl

ashwin-ant collaborator · 1 year ago

@xoma-zver's suggestion is correct. Please see the WSL troubleshooting instructions in the docs. You seem to have a Windows installation of npm instead of a Linux one.

underrealSKY · 1 year ago

Thank you, this was very helpful.

SpeedRanger · 1 year ago

Thanks, this worked for me!

joaopelisson · 1 year ago

It worked here! Thank you

effiompraise · 1 year ago

Thank you so much, @xoma-zver. I spent hours trying to figure this out until I found this solution. You saved me

mfouchi · 1 year ago

Thanks for this. I guess we're in the minority with windows workstations

dreydare · 1 year ago

Great. Seems this works

github-actions[bot] · 1 year ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.