2

UPDATE: I've been able to run prettier manually using

npx prettier --config .prettierrc --write .\force-app\main\default\classes

but I still cannot have it to work on save.

Hello everyone, I'm looking for some help with VS Code and Prettier

After some research I've found multiple possible solutions but none of them seems to be able to fix my problem. I installed Prettier and the Apex plugin following this tutorial: https://developer.salesforce.com/tools/vscode/en/user-guide/prettier.

Prettier is formatting my code perfectly for any language except Apex. For example, I can format a JSON or a lwc no proble. It's setup as the default formatter, I'm using Java SDK 11, my package and .prettierrc documents are configured and there is just no output when I save on an Apex class or trigger.

The plugin is installed locally and globally. you can see the versions and the sign that shows when I switch from a JSON to an Apex class for example.

Apex Plugin Version

Sign next to prettier when on Apex

Copy of my package

I was wondering if you had any ideas on how to fix this for me.

Thanks in advance, Oli

2
  • What's your Java version?
    – sfdcfox
    Commented Nov 16, 2021 at 0:11
  • I have Java SDK 11.0.13 and Java(TM) SE Runtime Environment 18.9 (build 11.0.13+10-LTS-370) ) Commented Nov 16, 2021 at 0:43

1 Answer 1

3

Lately, i have also experienced problem with Prettier new version. Can you try changing the devDependencies in package.json and use a previous version for Prettier plugin.

"prettier-plugin-apex": "^1.8.0"

After this try to install the Prettier again.

npm install prettier-plugin-apex
3
  • Thanks for the idea. I just changed it, run the npm install and still no success. Commented Nov 16, 2021 at 11:43
  • Can you try uninstalling npm first, install npm, change dependency and then install plugin. Commented Nov 16, 2021 at 21:16
  • I have been experiencing this same issue. I keep meaning to file a a bug on github Commented Nov 16, 2021 at 21:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .