2

After recently updating my VS Code, my prettier stopped working. The error says:

Extension 'Prettier - Code Formatter' cannot format (insert path here).

What I've tried to fix this issue,

  1. Setting the default formatter from 'null' to 'esbenp.prettier-vscode'
  2. Manually setting prettier as default formatter in settings.json enter image description here

3. Install/Uninstall the prettier extension 4. Install/Uninstall VS Code itself and wiping out all extensions installed

All of this doesn't work at all and I'm out of ideas on how to fix this issue.

Prettier Version: 5.8.0 VS Code Version: 1.51.5

maria
  • 363
  • 2
  • 5
  • 14

2 Answers2

0

From Sandstens answer, I got a solution working for myself. Just create a .prettierrc file in the root of your directory, and go to https://prettier.io/docs/en/configuration.html, copy the json config on the page, I'll paste it here for convenience:

{
 "trailingComma": "es5",
 "tabWidth": 4,
 "semi": false,
 "singleQuote": true
}

Then navigate to the file in your project and try seeing if it'll format upon save

JORDANO
  • 726
  • 8
  • 17
0

After having tried multiple methods (including all the ones you have maria) I've come across a fix that works, at least for me.

Steps

  1. Navigate to the root of your project
  2. Right click on the .prettierrc file
    • If you don't have this file, check out JORDANO's answer
  3. Select 'Copy Path'
  4. Press Cmd, (Mac) or Ctrl, (Windows)
    • Alternatively, go to File/Code > Preferences > Settings
  5. Search settings for prettier.configPath
  6. Finally, paste the path you copied on step 3

I came across this fix as I was scrolling through Prettier's settings and noticed the 'Prettier: Config Path' box was empty. Hopefully this helps anybody else that is having this problem. Make sure to try all the other methods maria tried if my fix doesn't work for you!

diego
  • 1
  • 1