15

In VS Code, When I select Format Document With... then choose Prettier - Code Formatter, I get the following error:

Command 'Format Document' resulted in an error (No loader specified for extension ".cjs", so searchPlaces item ".prettierrc.cjs" is invalid)

From what I can gather this has something to do with underlying TypeScript in VS Code not having a loader available for .cjs files and Prettier searching for prettierrc.cjs but I can't quite see how that all fits together, or how to work around it.

Has anyone else encountered, found a work around or solved this or a similar issue in VS Code?

Andrew Lewis
  • 1,251
  • 9
  • 16

1 Answers1

34

I tried disabling the Prettier VS Code extension and enabling it again and that fixed the issue for me.

Credits @NikolajDamLarsen

Dheeraj Bhaskar
  • 18,633
  • 9
  • 63
  • 66
  • 1
    I had to uninstall the extension completely but this seems to be solving the issue for others. – Andrew Lewis Oct 13 '20 at 06:15
  • To confirm the previous answers, either restarting VSCode or disabling+reloading+reenabling should work (whatever suits one better). Looks like a VSCode bug when specifying the name config file name: it saves the correct name to while forgetting what it saved. – gekkedev Jan 05 '21 at 17:13