Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

prettier throws error `Failed to resolve a parser`

Prettier throws error "failed to resolve a parser". Prettier is selected in Workspace, User and Python > Workspace, so I'm out of ideas why the error is thrown...

["INFO" - 08:57:18] File Info:
{
  "ignored": false,
  "inferredParser": null
}
["WARN" - 08:57:18] Parser not inferred, trying VS Code language.
["ERROR" - 08:57:18] Failed to resolve a parser, skipping file. If you registered a custom file extension, be sure to configure the parser.
like image 281
Ajax Avatar asked Oct 24 '25 16:10

Ajax


1 Answers

Did you by chance try to invoke the "Format Document (Forced)" command (prettier.forceFormatDocument) to trigger the formatting? (I would have asked you this with a comment first if only I had the required reputation to do so.)

I have seen the exact same error when I tried to invoke the command on a .cs file today.

Anyways, here's my...

attempted supportive answer

Since this command came from the "Prettier - Code formatter" extension (esbenp.prettier-vscode), it will only use the extension itself for formatting. Invoking it on any unsupported code only produces the log output you posted. (python and csharp are two unsupported ones)

It would seem that you already have some other extension for formatting python. If that extension is working, the regular command "Format Document" (alt-shift-F / cmd-shift-F) should be enough. But even if it doesn't work, it won't produce the same log output you posted.

Chances are, our respective formatter extensions actually worked, but it did not do the specific thing(s) we had in mind.

For my .cs files, I'm still looking at why my long IF statements are not broken down into multiple lines or why it does not format my indentation on the 2nd and 3rd lines of my multi-line IF statements.

"Isn't this what every prettier should do?"

I probably got this idea from my other projects (i.e. Typescript) which have every formatting needs fulfilled.

next step

You should probably ignore the log from prettier and focus on the log from autopep8 or the lacking of such.

like image 125
oopoopoop Avatar answered Oct 27 '25 07:10

oopoopoop