cli icon indicating copy to clipboard operation
cli copied to clipboard

[BUG] npm ERR! Error: EPERM: operation not permitted only on windows

Open testeur-990 opened this issue 10 months ago • 4 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

This issue exists in the latest npm version

  • [x] I am using the latest npm

Current Behavior

Hello,

For our dependency, Dash.js 5.0, we need to use Node 20.18.0, so npm 10.8.2 was installed with this Node version. However, when we run npm install on Windows, we encounter the error: ERR! Error: EPERM: operation not permitted, while it works fine on Mac.

Could you please assist us in fixing this issue with npm 10.8.2?

Expected Behavior

npm install works fine on windows as Mac

Steps To Reproduce

  1. In this environment : Windows
  2. With this config...
  3. Run : run npm install
  4. See error : npm ERR! Error: EPERM: operation not permitted only on windows

Environment

  • npm:10.8.2
  • Node.js:20.18.0
  • OS Name:Windows

testeur-990 avatar Jan 28 '25 20:01 testeur-990

@testeur-990 Based on the report It's hard to determine the cause of the issue but generally with windows if this occurs then you can try removing node_modules and reinstalling your dependency

milaninfy avatar Feb 04 '25 18:02 milaninfy

Hello @milaninfy , We tried what was mentioned and many other solutions we found, but we still have an issue with npm 10.8.2. I believe you can easily reproduce it by trying Node 20.18.0 with npm 10.8.2 on Windows (no issue on Mac).

For now, we have switched to Node 20.0.0, which uses npm 9.6.4, and it worked fine. We hope you can help us use npm 10.x.

Thank you

testeur-990 avatar Feb 05 '25 09:02 testeur-990

I suspect I'm seeing the same issue here -- https://github.com/TypeStrong/typedoc/actions/runs/13469139132

This job started failing randomly on Windows only after merging another branch. I tried several different versions of npm, downgrading some recently updated dependencies, but going back to 9.x doesn't seem to fix things for me... I'm tired of fighting it, and pnpm install seems to just work, so plan on going that route for now.

Gerrit0 avatar Feb 23 '25 05:02 Gerrit0

After so many trial and errors this chatgpt response saved my life. If it works for you i'll be more than happy.

If you're experiencing errors like cb.apply is not a function, EPERM: operation not permitted, or The "file" argument must be of type string, follow this guide to fully reset your Node.js & npm setup using nvm-windows.


Step 1: Uninstall Existing Node.js

  1. Go to "Add or Remove Programs"
  2. Uninstall anything named Node.js
  3. Delete the following folders (if they exist):

Remove-Item -Recurse -Force "$env:ProgramFiles\nodejs" -ErrorAction SilentlyContinue Remove-Item -Recurse -Force "$env:AppData\npm" -ErrorAction SilentlyContinue Remove-Item -Recurse -Force "$env:AppData\npm-cache" -ErrorAction SilentlyContinue


Step 2: Install nvm-windows

  1. Download the latest version from: 👉 https://github.com/coreybutler/nvm-windows/releases/latest

  2. Run the downloaded nvm-setup.exe file.


Step 3: Install Node.js 20 (LTS - Recommended)

Open PowerShell as Administrator, then run:

nvm install 20 nvm use 20

Verify Installation

node -v # Should show: v20.x.x npm -v # Should show: 9.x or 10.x


You're now using a clean, stable version of Node.js and npm via nvm. This should fix most environment-level issues.


pranay-dutta avatar Jun 07 '25 19:06 pranay-dutta