Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Next.js and React

The Prettier extension skips a file because no parser matches it

Your error

Failed to resolve a parser, skipping file. If you registered a custom file extension, be sure to configure the parser.1 more line it can show

Fix it fast

Most common cause, 1 of 3

The language is one Prettier does not format, such as Python

Keep Prettier for web files, remove any documentSelectors glob that matches .py, and give Python its own formatter under a [python] scope; install it first with code --install-extension ms-python.black-formatter.

Fix
// .vscode/settings.json or User settings.json
{
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "[python]": {
    "editor.defaultFormatter": "ms-python.black-formatter"
  }
}
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

Failed to resolve a parser, skipping file comes from the Prettier VS Code extension when it must format a file that neither Prettier nor a loaded plugin can parse. Give Python its own formatter, map a custom extension with an overrides parser, and list plugins like prettier-plugin-java under plugins. Applies to Prettier 3.10 and extension 12.4.

  • Applies to Prettier 3.10.1, Prettier - Code formatter extension 12.4.0
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Ask the Prettier installed in the project which parser it would use for the file. With ignored false, an inferredParser of null means Prettier, plus the plugins and overrides in your config, has nothing for it; a parser name means the problem is in the editor settings instead.

Run this first
node --input-type=module -e "import * as p from 'prettier'; console.log(await p.getFileInfo('src/main.py'))"

Then find the line you see in this list and open its fix:

  1. 1The language is one Prettier does not format, such as PythonThe error shows on .py files (or Go, Rust, C#), after Format Document (Forced) or with a prettier.documentSelectors glob that matches every file
  2. 2A custom file extension has no parser assignedprettier.documentSelectors lists an extension of your own, such as **/*.tmpl, but the Prettier config has no override for it
  3. 3The plugin for that language is installed but not loadedThe file is PHP, Java, XML, Svelte, Astro or another plugin language, the plugin package is in node_modules, and the config has no plugins entry

What does the error look like?

  • Failed to resolve a parser, skipping file. If you registered a custom file extension, be sure to configure the parser.
  • Parser not inferred, trying VS Code language.

Cause 1 of 3

The language is one Prettier does not format, such as Python

You seeThe error shows on .py files (or Go, Rust, C#), after Format Document (Forced) or with a prettier.documentSelectors glob that matches every file

Check

The parser cannot be resolved because Prettier core covers JavaScript and web-focused languages only: JSX, Flow, TypeScript, CSS, Less, SCSS, HTML, Vue, Angular, Handlebars, JSON, GraphQL, Markdown, YAML and a few more. The extension registers itself for those languages, so a Python file reaches it only through the forced command or a broad documentSelectors pattern, and then it gives up.

Check
grep -n "documentSelectors\|defaultFormatter" .vscode/settings.json

Fix

Keep Prettier for web files, remove any documentSelectors glob that matches .py, and give Python its own formatter under a [python] scope; install it first with code --install-extension ms-python.black-formatter. Black and autopep8 are published by Microsoft, and Ruff appears in the community list of the VS Code Python docs.

Fix
// .vscode/settings.json or User settings.json
{
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "[python]": {
    "editor.defaultFormatter": "ms-python.black-formatter"
  }
}

Verify

Format Document on a .py file now runs Black, and the Prettier output panel stays quiet for it.

Verify
code --list-extensions | grep -i black-formatter

Confirmed by code.visualstudio.com

Did this fix it?

Cause 2 of 3

A custom file extension has no parser assigned

You seeprettier.documentSelectors lists an extension of your own, such as **/*.tmpl, but the Prettier config has no override for it

Check

Prettier picks a parser from the file extension. A pattern in prettier.documentSelectors makes the extension accept such files, yet Prettier still cannot tell how to parse them, and the VS Code language id does not help either. The extension README says such a selector needs a matching override, which is why the message mentions custom file extensions.

Check
cat .prettierrc

Fix

Add an overrides entry that names the files and the parser Prettier should use for them.

Fix
{
  "overrides": [
    {
      "files": ["*.tmpl"],
      "options": { "parser": "html" }
    }
  ]
}

Verify

getFileInfo now returns the parser you set, and saving the file formats it.

Verify
node --input-type=module -e "import * as p from 'prettier'; console.log(await p.getFileInfo('views/page.tmpl'))"

Confirmed by raw.githubusercontent.com

Did this fix it?

Cause 3 of 3

The plugin for that language is installed but not loaded

You seeThe file is PHP, Java, XML, Svelte, Astro or another plugin language, the plugin package is in node_modules, and the config has no plugins entry

Check

Prettier 3.0 removed the automatic plugin search, so a plugin is used only when you name it through the plugins option, the --plugin flag or the API. An installed package that the config never mentions leaves the file without a parser, and the extension does not register itself for that language either.

Check
npm ls --depth=0 | grep -i prettier

Fix

List the plugin in the Prettier config. Strings in plugins are passed to import(), so the package name is enough when it is installed in the project.

Fix
npm install --save-dev prettier prettier-plugin-java

// .prettierrc
{
  "plugins": ["prettier-plugin-java"]
}

Verify

The CLI formats the file with the plugin loaded through the config.

Verify
npx prettier --check src/Main.java

Confirmed by prettier.io

Did this fix it?

How do I stop it coming back?

  • Set editor.defaultFormatter per language in a committed .vscode/settings.json instead of one global value for everything.
  • Keep every Prettier plugin in devDependencies and in the plugins list of the same config file, and review both in one change.
  • Run npx prettier --check in CI so a file type with no parser shows up as an error there, not only in one editor.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.