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
},
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
Solution for pre-commit users
I asked for more solutions on their repo, but for now you could choose one of the two above.