prettier-vscode: prettier failing with the new update of vs code (1.33)

With the new version of VS Code my prettier doesn’t format any longer.

from my settings: "[javascript]": { "editor.formatOnSave": true, "editor.defaultFormatter": "esbenp.prettier-vscode" }

The error I get: image

image

EDIT: It seems to work when I install prettier as a devdependency, of course, I don’t want to be doing this on every project.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 7
  • Comments: 19 (1 by maintainers)

Most upvoted comments

This issue seems to be improved by the updates in the VS Code 1.35 release (May 2019):

This update brings TypeScript language improvements, along with tooling enhancements for both JavaScript and TypeScript. It also fixes a number of important bugs, including fixes for performance issues that some users were seeing when working with styled-components.

When running the Format With… command, the default formatter is now pre-selected.

The key to fixing this error and having everything working was to set Prettier as the default formatter.

Here’s how I have VS Code and Prettier configured:

Here’s the relevant part of my settings.json:

"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"[javascript]": {
  "editor.formatOnSave": true,
  "editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[php]": {
  "editor.defaultFormatter": "fterrag.vscode-php-cs-fixer"
}

With this configuration, JavaScript files will be automatically formatted on save by Prettier.

Tested using VSCode 1.35.1 with Prettier 1.9.0 on macOS 10.14.5 “Mojave”.

Same issue, 1.33.1

Had the same issue, @ryanjbonnell’s solution worked for me

I have the same issue with v.1.33.1 Here’s my settings.json

"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.wordWrap": "on",
"editor.autoIndent": true,

None of these work, not even autoIndent