pnpm: EPERM: operation not permitted, chmod

pnpm version: 6.14.2

Code to reproduce the issue:

 ERROR  EPERM: operation not permitted, chmod '/Users/hronro/Projects/my-project/node_modules/.pnpm/rimraf@3.0.2/node_modules/rimraf/bin.js'
at pnpm/rimraf

Additional information:

  • node -v prints: v16.6.2
  • Windows, macOS, or Linux?: macOS

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 7
  • Comments: 42 (9 by maintainers)

Most upvoted comments

@zkochan I fixed this by deleting the whole pnpm global cache directory. I guess there are some files with incorrect permissions in the global cache directory.

Fixed it on Linux deleting this folder: ~/.local/share/pnpm/store/v3/files

rm -r ~/.local/share/pnpm/store/v3/files

This may be related: https://github.com/pnpm/pnpm/issues/2343#issuecomment-893486787

I had an issue where mkdirp@1.0.4/node_modules/mkdirp/bin/cmd.js ended up with root:wheel ownership. That caused me to get ERROR  EPERM: operation not permitted, chmod ‘/path/to/my/project/node_modules/mkdirp/bin/cmd.js’ when attempting to pnpm install. Running rm -rf node_modules in my project and reinstalling the package didn’t fix it nor did trying to pnpm install mkdirp in a new/empty test project, but rm -rf node_modules && rm -rf $HOME/.pnpm-store and then reinstalling did fix it. So my guess is some files in that package had gotten corrupted in the store somehow.

I use sudo pnpm install resolve it

fixed this problem after running pnpm store prune See: https://pnpm.io/cli/store

What command were you running?

I got this whenever I run pnpm i

Downgrading to pnpm 7 fixed it for me npm i -g pnpm@7. Looks like pnpm 8 is so fast that Windows unlocks files after using them slower than pnpm tries to use them again.

After i deleted the /Users/${user}/.pnpm-store directory, re-run pnpm i in my project and it worked. May be this command really needs. #2343

For me in windows, I had to remove the pnpm folder on the %USERPROFILE%\AppData\Local path and the installing it again using npm i -g pnpm

After i deleted the /Users/${user}/.pnpm-store directory, re-run pnpm i in my project and it worked.
May be this command really needs. #2343

(base) ➜ frontend git:(main) rm -r ~/.local/share/pnpm/store/v10/files

Fixed it on Linux deleting this folder: ~/.local/share/pnpm/store/v3/files rm -r ~/.local/share/pnpm/store/v3/files

Fixed for me, thank you!

Different version for me, ~/.local/share/pnpm/store/v10/files (there’s an index in there too, but doesn’t seem to make any difference), but it worked.

Worked for me rm -r ~/.local/share/pnpm/store/v10/files

pnpm@10.0.0 wsl2

rm -r ~/.local/share/pnpm/store/v3/files

This command fixed my issue on Ubuntu, thanks @Bosphoramus

@Bosphoramus That fixed it for me on linux. Thanks

Even with an administrator commandline on windows I get the same error. I got the same error on several projects , and I couldn’t resolve it , so sadly I had to get back to the old npm. Windows 10 Nodejs v18.15.0 Nextjs

deleting the whole pnpm global cache directory.

ok but how did you do that?