I ran into this error while using a .prettierrc.json file, and the problem was that the file was encoded in UTF-16LE, not UTF-8. Saving the file as UTF-8 fixed this for me.
The root cause of this issue was following the documentation that recommended echo {}> .prettierrc.json to create the file. On Windows powershell, this creates a UTF-16LE file, not a UTF-8 file.
More discussion can be found at this github issue
Answer from Luke Miller on Stack Overflow
» npm install prettier-plugin-packagejson
I ran into this error while using a .prettierrc.json file, and the problem was that the file was encoded in UTF-16LE, not UTF-8. Saving the file as UTF-8 fixed this for me.
The root cause of this issue was following the documentation that recommended echo {}> .prettierrc.json to create the file. On Windows powershell, this creates a UTF-16LE file, not a UTF-8 file.
More discussion can be found at this github issue
According to https://prettier.io/docs/en/configuration.html configuration in package.json has the highest precedence, so you should be able to call:
prettier ./src/basic-sample.js
or
prettier --write ./src/basic-sample.js
I'm doing this from within an package.json script, but that shouldn't make any difference.
» npm install prettier-plugin-package
» npm install @prettier/plugin-php
» npm install eslint-plugin-prettier