0

I get the following error when trying to run any npm/gulp command in Git Bash/PS

npm install
internal/fs/utils.js:269
    throw err;
    ^

Error: EPERM: operation not permitted, lstat 'C:\Users\<admin user account>'
←[90m    at Object.realpathSync (fs.js:1646:7)←[39m
←[90m    at toRealPath (internal/modules/cjs/loader.js:336:13)←[39m
←[90m    at Function.Module._findPath (internal/modules/cjs/loader.js:492:22)←[39m
←[90m    at resolveMainPath (internal/modules/run_main.js:12:25)←[39m
←[90m    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:54:24)←[39m
←[90m    at internal/main/run_main_module.js:17:47←[39m {
  errno: ←[33m-4048←[39m,
  syscall: ←[32m'lstat'←[39m,
  code: ←[32m'EPERM'←[39m,
  path: ←[32m'C:\\Users\\<admin user account>'←[39m
}
internal/fs/utils.js:269
    throw err;
    ^

Error: EPERM: operation not permitted, lstat 'C:\Users\<admin user account>'
←[90m    at Object.realpathSync (fs.js:1646:7)←[39m
←[90m    at toRealPath (internal/modules/cjs/loader.js:336:13)←[39m
←[90m    at Function.Module._findPath (internal/modules/cjs/loader.js:492:22)←[39m
←[90m    at resolveMainPath (internal/modules/run_main.js:12:25)←[39m
←[90m    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:54:24)←[39m
←[90m    at internal/main/run_main_module.js:17:47←[39m {
  errno: ←[33m-4048←[39m,
  syscall: ←[32m'lstat'←[39m,
  code: ←[32m'EPERM'←[39m,
  path: ←[32m'C:\\Users\\<admin user account>'←[39m
}

I have my environment variables set up for my Path to point to the nodejs folder in Program Files for both my admin and regular user account but can still only run npm and gulp commands as an admin. This happens in any location on that C drive but other commands (eg. dotnet, node) work fine in both users.

  • 1
    Does this answer your question? [npm - EPERM: operation not permitted on Windows](https://stackoverflow.com/questions/34600932/npm-eperm-operation-not-permitted-on-windows) – tornadoradon Apr 14 '23 at 14:11
  • Thanks @tornadoradon but this still hasn't resolved my issue. I've realised that nvm has installed my node versions into my admin account, which I believe may have still ben accessible in the past from my nodejs folder but is now inaccessible for my regular user. I'll try installing nvm for my regular user – Isaac Richardson Apr 17 '23 at 09:01

1 Answers1

0

It looks as though the issue was related to where my nvm was installing each node version.

nvm installed each version into a nodejs file under the nvm directory in my admin user account and the path variable was pointing to a nodejs folder in my Program Files which was actually a short cut to that admin user account. Since this was inaccessible, all the npm commands were failing.

I've switched the root path for nvm by:

  1. Opening cmd as admin
  2. Running nvm root to check the current root (this was within my admin user folder eg. C:\Users\<admin user>\AppData\Roaming\nvm)
  3. Delete the C:\Program Files\nodejs shortcut folder
  4. Create a C:\Program Files\nodev folder
  5. Run nvm root "C:\Program Files\nodev" to set the root to a new nodev folder in Program Files to hold the node versions installed via nvm
  6. Re-install a version of npm using nvm
  7. Open a cmd window as a non-admin and run node -v to confirm the correct node verion is in use and run npm -v to confirm npm can be used