prettier: Unable to run prettier 3.0.0 with error node_modules/.bin/prettier: Permission denied

Environments:

  • Prettier Version: 3.0.0
  • Running Prettier via: pnpm, npx, etc… doesn’t appear to matter.
  • Runtime: pnpm 7.14.1, node 16.16.0
  • Operating System: macOS
  • Prettier plugins (if any):

Steps to reproduce:

Install prettier as per the docs (in my case pnpm)): https://prettier.io/docs/en/install.html

Expected behavior:

npx prettier should run.

Actual behavior:

Executing: npx prettier

Yields: sh: /Users/mrmagoo/Development/mobile/react-native-app/node_modules/.bin/prettier: Permission denied

Looking at the premissions of ./bin.prettier:

lrwxr-xr-x  1 mrmagoo  staff  28 Jul 27 18:12 node_modules/.bin/prettier -> ../prettier/bin/prettier.cjs
...
-rw-r--r--  2 mrmagoo  staff   2.1K Jul 25 12:55 node_modules/prettier/bin/prettier.cjs

If i grant execute permissions to node_modules/prettier/bin/prettier.cjs it all works as expected.

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 5
  • Comments: 17 (9 by maintainers)

Most upvoted comments

I think this happened to me couple times after prettier got updated in our repo. The fix was to remove node_modules/.bin/prettier and run yarn again

I’ve been seeing this recently with prettier installed via yarn. I wonder if https://github.com/yarnpkg/berry/issues/5344 is at fault.

uninstall and reinstall, solve it.