Notification texts go here Contact Us Buy Now!

How do I specify a specific prettier version in a VSCode .devcontainer?

How do I specify a specific prettier version in a VSCode .devcontainer?

You can set the version in the .devcontainer like this:

"extensions": ["esbenp.prettier-vscode@8.0.1"],

The trick is you also have to turn off extension automatic updates:

"settings": { "extensions.autoCheckUpdates": false, "extensions.autoUpdate": false },
Note: This turns off automatic updates for all extensions.

Also, RUN npm install prettier@2.2.1 -g -D --save-exact in the Dockerfile adds the prettier CLI to the environment, not the VS Code extension.

Best solution: install Prettier into your project

If your project uses Prettier, then Prettier should be one of its dependencies:

npm install --save-dev prettier

This is how you can strictly control which version a project uses.

Solution for occasional formatting

If you want to use Prettier on random files, you can ask it to use the version you installed globally

npm install --global prettier

And then set the setting in VS Code

Prettier: Resolve 
    Global Modules

Solution for pre-commit users

I asked for more solutions on their repo, but for now you could choose one of the two above.

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.