Been using prettier in vscode for a while, but it recently stopped working and I'm not sure if it's a bug on their end or a misconfiguration of mine.
["INFO" - 02:54:03] Loaded module '[email protected]' from '/Users/paulrberg/.nvm/versions/node/v10.17.0/lib/node_modules/prettier'
["INFO" - 02:54:03] Formatting using 'prettier-eslint'
["ERROR" - 02:54:03] Error formatting document.
r is not a function
TypeError: r is not a function
at /Users/paulrberg/.vscode/extensions/esbenp.prettier-vscode-3.13.0/dist/extension.js:1:352891
at t.default.safeExecution (/Users/paulrberg/.vscode/extensions/esbenp.prettier-vscode-3.13.0/dist/extension.js:1:353582)
at t.default.<anonymous> (/Users/paulrberg/.vscode/extensions/esbenp.prettier-vscode-3.13.0/dist/extension.js:1:352865)
at Generator.next (<anonymous>)
at s (/Users/paulrberg/.vscode/extensions/esbenp.prettier-vscode-3.13.0/dist/extension.js:1:347571)
Open up VSCode settings in UI mode by selecting File > Preferences > Settings or press Ctrl + ,. Input “formatter” in the search box. Once you see Editor: Default Formatter section, select . This setting allows you to define a default formatter which takes precedence over all other formatter settings.
This article will guide you through setting up Prettier to format your code in Visual Studio Code automatically. For demo purposes, here’s the sample code we will be formatting. If you’re picky about code formatting, you might pick up on some apparent missteps immediately.
Make sure your Editor: Default Formatter field is not null but rather esbenp.prettier-vscode and that all the languages below are ticked. This fixed my issue. I did this and also tried the solution from @miha to no avail. Finally uninstalled/reinstalled and it worked Sometimes, prettier stops working when there are syntactic errors in the code.
This is not a problem with Prettier itself, but prettier-vscode, the VSCode extension. According to its documentation, Vue formatting is disabled by default: A list of languages IDs to disable this extension on. Restart required.
To work with Prettier in Visual Studio Code, you’ll need to install the extension. Search for Prettier - Code Formatter. You can see the extension below. If you’re installing it for the first time, you’ll see an “install” button instead of the “uninstall” button you see on mine.
There was a bug in version 3.13.0. Upgrade to the latest and the issue will go away.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With