Search code examples
prettier

Prettier doesn't format my code in Visual Studio on Next.js


Prettier has worked fine on my projects to date.

I just started a new next.js project, and while problems are reported in the terminal window, and the prettier extension is a dev dependency for the project, it does nothing to format my code. the little lightbulb does not appear anywhere (just red underline).

Is there something special required for SSR?enter image description here


Solution

    1. Make sure that Prettier is enabled as your default formatter. See here for details on how to do that.
    2. Make sure that Format On Save is enabled, or that you're calling the formatting option manually.
    3. Resolve all errors, then try again. Personally, Prettier refuses to format if there are any errors. Warnings are fine, but only if all errors are resolved does Prettier perform formatting, on my projects.