question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prettier does not work as default formatter in VS Code 1.57.1 on Windows.

See original GitHub issue

Summary

I have the Prettier extension installed, have the prettier npm package installed globally and in this project. It seems as though the Prettier extension is not starting and is missing in the VS Code status bar.

image

When I try to save a file that I know to have no errors, I get the error "Extension 'Prettier - Code fromatter' cannot format 'src\index.js'"

My relevant settings:

{
  "editor.formatOnPaste": true,
  "editor.formatOnSave": true,
  "editor.defaultFormatter": "esbenp.prettier-vscode"
}

Manually formatting doesn’t work either. Running prettier in the command line does correctly format the file.

Short summary of what is going on or to provide context.

It works fine on my Mac. Both VS Code installations are fine and settings are synced.

Github Repository to Reproduce Issue

Link to a Github repo that can be used to reproduce the issue.

Steps To Reproduce:

  1. Install Prettier extension
  2. Try to save a file
  3. Alternatively, try to format manually.

Expected result

The file should have been formatted upon saving it.

Actual result

I get the error "Extension 'Prettier - Code fromatter' cannot format 'src\index.js'"

Additional information

Feel free to attach a screenshot.

VS Code Version:

Version: 1.57.1 (user setup) Commit: 507ce72a4466fbb27b715c3722558bb15afa9f48 Date: 2021-06-17T13:28:07.755Z Electron: 12.0.7 Chrome: 89.0.4389.128 Node.js: 14.16.0 V8: 8.9.255.25-electron.0 OS: Windows_NT x64 10.0.18363

Prettier Extension Version: 8.0.1

Prettier Log Output

Cannot create log output, because Prettier is missing from the toolbar.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:19 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
W2AlharbiMecommented, Jul 2, 2021

okay after i updated my vscode to latest version, prettier stopped working i got the following message when i save a file at the bottom left: “prettier was unable to format /…/…/…/”

so after disable prettier and enable it again i set it as the default formatter and now its working correctly but i don’t know what happened exactly my vscode theme was reset to the default

vscode version: 1.57.1

1reaction
yurtkurancommented, Jun 30, 2021

Having the same issue on a Mac

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does Prettier not format code in VS Code? - Stack Overflow
Open Files -> Preferences -> Settings (or Ctrl + , in Windows). Search for Editor: Default Formatter; Select your default formatter as Prettier ......
Read more >
Prettier - Code Formatter not working on save (Help) : r/vscode
Mine stopped working with the new update too. Setting Prettier as the default formatter seems to solve the glitch. I'd suggest you do...
Read more >
How to enable auto format on save with prettier in VS Code ...
Explainer video about How to enable auto format on save in VS Code ( Visual Studio Code ) editor with prettier code formatter...
Read more >
How to fix Prettier Extension not working issue in VS CODE
0:00 · New! Watch ads now so you can enjoy fewer interruptions. Got it.
Read more >
How To Format Code with Prettier in Visual Studio Code
Note: If you do not see a prompt for selecting a default format, you can manually change this in your Settings. Set Editor:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found