Well, I am trying to set up code formatting process in my project and I am following this guide Set Up the Prettier Code Formatter for Salesforce Projects where steps 1 and 2 include installing prettier locally.

Does anybody know why this is needed? As far as I understand, installing the Prettier extension for VS Code, which is step 5 in the guide, already gives formatting functionality and recognizes the .prettierrc file in the project root. What is the purpose of having prettierinstalled via npm alongside Prettier vs code extension?

2 Answers 2


From Docs for Prettier at VisualStudio Marketplace:

This extension will use prettier from your project's local dependencies. Should prettier not be installed locally with your project's dependencies, a copy will be bundled with the extension.

This implies you don't need to install prettier locally using npm.

But its always good to have prettier installed locally,, just in case you wanna use it via commandline , Batch Scripts or some CI CD jobs to autoformat code.

Src : https://prettier.io/docs/en/cli.html

  • Thanks! Now it's much clear to me.
    – Eduard
    May 21, 2019 at 14:22

The command npm install --save-dev --save-exact prettier makes sure that your project has prettier as local dependencies .

If you read through the https://github.com/prettier/prettier-vscode specially resolution section it looks for prettier first in the local dependency and hence its ok to install it as dev dependency before the extension is installed .

Also using --save-exact locks to specific version of prettier making it consistent.

You must log in to answer this question.

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