Prettier Code Formatter for VS code fails with 'No loader specified for extension ".cjs"'

2.4k Views Asked by At

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?

1

There are 1 best solutions below

2
On BEST ANSWER

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

Credits @NikolajDamLarsen