I am confused with how the extensions in VS Code work. The "Prettier - Code formatter" extension (by Esben Petersen) is already installed as an extension in my VS Code. My question is why I still need to run npm install prettier --save-dev in each individual project? Isn't it true that the extensions are already applied to all files?

2

Best Answer


You don't?

Should prettier not be installed locally with your project's dependencies or globally on the machine, the version of prettier that is bundled with the extension will be used.

https://github.com/prettier/prettier-vscode#prettier-resolution

It seems like you want Prettier to be your code formatter in VS Code for all of your projects.

In VS Code navigate to:

File > Preferences > Settings

Search for "Default formatter"

And then select "esbenp.prettier-vscode"