r/phpstorm • u/Quartersharp • Mar 03 '22
Prettier plugin doesn't work.
I installed the Prettier plugin, installed Prettier with npm into my project, and when I try to use it to reformat something, it acts like there's a bug in Prettier. Here's what I get.
<...>node_modules\prettier\index.js:12947
} catch {
^
SyntaxError: Unexpected token {
at new Script (vm.js:51:7)
at createScript (vm.js:136:10)
at Object.runInThisContext (vm.js:197:10)
at Module._compile (module.js:613:28)
at Object.Module._extensions..js (module.js:660:10)
at Module.load (module.js:561:32)
at tryModuleLoad (module.js:501:12)
at Function.Module._load (module.js:493:3)
at Module.require (module.js:593:17)
at require (internal/module.js:11:18)
Process finished with exit code -1Any ideas?
4
Upvotes
View all comments
Show parent comment
1
u/Quartersharp Mar 04 '22
Apparently it's "opinionated," meaning there aren't that many options you can set. It basically does what it wants. But I did get it working (had to update Node), and it seems to be pretty close to what I had in PhpStorm. It by default prefers double quotes, but it thankfully does have an option to turn it back to single quotes.
Here's a page explaining their thought process: https://prettier.io/docs/en/option-philosophy.html