Do I really need to install Prettier locally?

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


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.

Tags:

Vs Code