prettier-vscode: Version 8.0.0 errors with "Extension 'Prettier - Code Formatter' cannot format" on all documents

Any time I attempt to format a JSON document in 8.0.0 I get the error:

Extension 'Prettier - Code Formatter' cannot format '<document>.json'

I see no log files to assist with troubleshooting this.

Based on other users’ reports, this issue appears to be happening for more than just JSON; formatting itself might not be working at all on 8.0.0.

This issue doesn’t happen when rolling back to 6.4.0.

my versions:

prettier: ^2 via yarn v2 pnp prettier-vscode: 8.0.0 vscode: 1.57.1


To users experiencing this issue, you may roll back using the following steps:

  1. Go to the extensions tab
  2. Find the prettier extension
  3. Click on the settings cog
  4. Install another version...
  5. Select your desired version

Per the changelog, you should not use v7

https://github.com/prettier/prettier-vscode/blob/main/CHANGELOG.md#700

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 82
  • Comments: 29 (2 by maintainers)

Most upvoted comments

Fixed in 8.0.1 - hopefully for good.

@kevin-lindsay-1 thank you for the walk-through, rolling back to 6.4.0 worked for me.

For the record, downgrading to 7.1.1 worked for me for formatting typescriptreact code.

Fixed in 8.0.1 - hopefully for good.

I still saw this issue and VS Code said 8.0.1 was installed BUT quitting and restarting VS Code did the trick and it is now working. 👍 (and it says 8.0.1 installed)

😃) “nice” update with error “can not format” ! v8.0.0 break 😄 roll back to 7.1.1 for fixing issue

When I save, prettier is removing a newline at the end of the file in v8, so I rolled back to v6. Why is it doing that?

Getting this error too. Opening the devtools tells me Activating extension 'esbenp.prettier-vscode' failed: Cannot find module 'prettier'

image

@TorrenceB

I’ve updated the original post with instructions.

Hi @kevin-lindsay-1,

The prettier extension has been formatting files fine for me for months 😄 I know about the syntax error issue as it’s a daily occurence for me.

I’ve finally got it working… I fixed it with:

rm -r ~/.vscode-server-insiders

So it was vscode that was messed up… which is trange since it also was happening on a fresh clean install of VS Code (not insiders),

@kylekirkby this issue was fixed the day it happened, and by default VS Code updates extensions automatically, and I haven’t seen this issue return.

I don’t use insiders, but it doesn’t appear obvious that insiders would be causing the problem if JSON is working.

Were your JS files being formatted correctly, specifically by prettier and not the default formatter, before?

Also, if you have a syntax error in a file prettier would probably not format it.

Additionally, this issue was specifically present in 8.0.0 and it broke the extension pretty much entirely; it was fixed in a patch about an hour later. You shouldn’t need to downgrade, but if it still doesn’t work after downgrading the issue is likely your setup/code. Do you have any messages coming from your linter?

Getting the same issue. Works when I roll back to 7.1.1 though.