Reputation: 31
I am trying to format my code using Prettier, but when I try to format it by saving the file, by clicking "Format document with" or by any other way it just doesn't format and the Prettier button turns red and appears this !
icon.
I reinstalled VS Code and Prettier hundreds of times. Any idea of how I can fix this?
Here are the images of what is happening:
Image of the red button:
When I click, it returns to its normal color, but nothing happens
Upvotes: 1
Views: 979
Reputation: 162
I followed these steps suggested by @sanjarcode but additionally, and probably more relevant is that I had not yet made Prettier my default formatter.
So I:
prettier
as a Dev dependency.prettierrc
containing {}
cmd
and ,
to open VS Code settings and searched for "default formatter". I then set this to Prettier - Code formatter
.From then the Red button / issues warning was no more as I had previously set my formatting to work on save and saved any files it was showing in.
Upvotes: 0
Reputation: 570
There are two cases here, you're either working on a:
package.json
) - delete any unnecessary package.json
files from current folder and immediate parent folders.package.json
file) - Run npm install
, or npm install prettier --save-dev
(in the terminal at the folder level) if it still doesn't work.I had the same problem. In my case, I had a useless package.json
file in the parent folder, which was causing all the issue. I was working on a simple HTML, CSS and JS project.
Upvotes: 0