Search code examples
javascriptvisual-studio-codeprettier

Next.js 11 - Prettier cannot format pageName.js


My prettier extension in VSCode quit working. Earlier today it was working without any issues. I am getting an error that reads:

prettier cannot format "pageName.js"

I am currently using the recently released version of prettier (v8.0). I tried re-configuring the formatter, as well as reinstalling it, however; all of my attempts to solve the issue failed. Does anyone know what is going on with prettier, could their be a problem with the latest update? Is anyone else experiencing this problem?


Solution

  • I decided to try and recreate the issue you that you were experiencing. I didn't have to do much, as I immediately noticed I was also experiencing the same issue.

    EDIT:

    At this point I can confirm that they had issues with sem-var & major-ver numbering they used. All of the major-version v7.x.x doesn't appear to work, they bumped to v8.0, but that didn't work either. I can confirm that 8.1 is the working version. Before this edit v6.4 was the version that solved the issue, but now you should be good with anything v8.1.0 and up.

    END EDIT

    I used v6.4 initially, it worked, so I stuck with that until v8.1 released. After v8.1 prettier seems to be working fine. It looks as though they are experiencing some problems because the extension explorer is showing a release of Version 7 & Version 8 an hour ago.

    You can see the version releases here:

    enter image description here

    To fix the issue:

    1. Open op the extension view from your activity bar.
    2. Search for prettier, Click on the standard Prettier Extension (should have 13m Downloads)
    3. Up top, next to the UNINSTALL BUTTON is an ARROW click the arrow to open up the different versions you are able to install.
    4. Hit version 8.2.0 or newer or 6.4.0 or older
    5. After it downloads completely restart your editor.

    enter image description here

    Now Prettier should work as expected.