The parser option babylon has been removed in Prettier 2.0
Error message:
Prettier format failed
[Error - 10:52:04 p.m.] Couldn't resolve parser "babylon"
The fix: https://github.com/vuejs/vetur/blob/master/server/src/modes/script/javascript.ts#L484
Replace babylon with babel
Format a Vue File using prettier 2.0
I'm also using prettier 2.0 and am having troubles when this plugin undoes the formatting in the git repo.
At the moment I just told vscode to give preference to the prettier-vscode plugin when formatting.
Anyone news?
@rnenjoy
This is the setting I have in my .vscode/settings.json
{
"[vue]": {
// Vetur uses an old version of prettier
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
This is specific enough that it doesn't mess with my other formatting options and fixes the problem with vue files.
@rnenjoy
This is the setting I have in my.vscode/settings.json{ "[vue]": { // Vetur uses an old version of prettier "editor.defaultFormatter": "esbenp.prettier-vscode" } }This is specific enough that it doesn't mess with my other formatting options and fixes the problem with
vuefiles.
Not an option for me since that affects the whole .vue file and I don't use prettier to format my template, only the script tag.
For now i went into the extension code, and changed babylon to babel manually. Tell me if you guys need help which file to edit.
@rnenjoy how do you do that?
@rnenjoy how do you do that?
Sorry for the delay:
Goto %USERPROFILE%.vscode\extensions\octref.vetur-0.24.0\server\dist\modes\script\javascript.js
Change 398
const parser = scriptDoc.languageId === 'javascript' ? 'babylon' : 'typescript';
to
const parser = scriptDoc.languageId === 'javascript' ? 'babel' : 'typescript';
@rnenjoy just add this line to your .vscode/settings.json file "vetur.format.defaultFormatter.html": "none" it should help you.
Most helpful comment
@rnenjoy
This is the setting I have in my
.vscode/settings.jsonThis is specific enough that it doesn't mess with my other formatting options and fixes the problem with
vuefiles.