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
🌐
Prettier
prettier.io › docs › cli
CLI · Prettier
Use the prettier command to run Prettier from the command line.
🌐
Fishtank
getfishtank.com › insights › running-prettier-from-the-command-line
Running Prettier from the Command Line | Fishtank
March 21, 2023 - Now format all files with Prettier by running - npm run format in your terminal. This command will pick up “format” inside “script” in your project’s package.
Discussions

Format your code using prettier without null-ls! Just vanilla vim
:h formatprg may be more complicated to setup but it comes in handily because it lets you to use formatters with motions using gq which is nice if you don’t want to format the whole file every time More on reddit.com
🌐 r/neovim
18
52
June 29, 2023
Why does prettier not show up when the 'which prettier' command is typed?
Let’s take a step back — which shows you the full path to executables added to your PATH — run man which in your terminal to see the documentation on this. If you don’t understand how PATH works, take a look at this http://www.linfo.org/path_env_var.html Long story short is, when you add an executable to the PATH env variable (it’s a colon : separated list of executables), it will be discoverable regardless of which directory you are in. So now the JS stuff, re: prettier — By running npm install —save-dev prettier you are adding the prettier executable under the current directory in node_modules/.bin/prettier - it is not available globally because isn’t added to $PATH. This is why which can’t find it. If you want to run prettier in any directory, you will need to globally install it; i.e. npm i -g prettier && which prettier. Or if you’re only using it within this directory/project, one common pattern is exposing the executable through npm run scripts in package.json. Docs: https://docs.npmjs.com/cli/run-script Once you add it to the scripts field in package.json, you can run it within in project using npm run [your script name]. I’m on mobile so apologies for the typos More on reddit.com
🌐 r/learnprogramming
7
2
January 20, 2020
How do I use the CLI to fix all files?
I apologize if this is a stupid question. We have a large monorepo containing lots of projects. We need to specify the exact set of paths to be processed by Prettier. It's not okay for Prettier to ... More on github.com
🌐 github.com
19
July 9, 2019
autocommand to run neoformat prettier on js, ts, jsx and tsx files on save, in lua syntax?
Off the top of my head it's something like vim.api.nvim_create_autocmd("BufWritePre", { pattern = { "javascript", "javascriptreact", "typescript", "typescriptreact" }, command = "Neoformat prettier", }) edit: I just looked at your config a bit. If you want to roll it together with eslint fixing, vim.api.nvim_create_autocmd("BufWritePre", { pattern = { "javascript", "javascriptreact", "typescript", "typescriptreact" }, callback = function() vim.cmd("EslintFixAll") vim.cmd("Neoformat prettier") end, group = autogroup_eslint_lsp, }) Haven't bothered looking where this EslintFixAll is coming from but that should do it. More on reddit.com
🌐 r/neovim
2
4
January 22, 2022
🌐
Prettier
prettier.io › docs › install
Install · Prettier
--check is like --write, but only checks that files are already formatted, rather than overwriting them. prettier --write and prettier --check are the most common ways to run Prettier.
🌐
JetBrains
jetbrains.com › help › webstorm › prettier.html
Prettier | WebStorm Documentation
In the Settings dialog (Ctrl+Alt+S) , go to Languages & Frameworks | JavaScript | Prettier. In the Run for files field, specify the file patterns to which Prettier will be applied automatically when such files are saved or when the Reformat ...
🌐
DEV Community
dev.to › bokub › how-to-properly-set-up-prettier-in-less-than-2-minutes-2ld0
How to properly set up Prettier in less than 2 minutes - DEV Community
July 5, 2022 - The setup can be a little bit long if you actually read the whole documentation, but here are the commands you need to run to set everything up: # With npm npx husky-init npm i -D pretty-quick npx husky set .husky/pre-commit "npx pretty-quick --staged" # With yarn npx husky-init yarn add -D pretty-quick yarn husky set .husky/pre-commit "npx pretty-quick --staged" That’s it ! You will now see this kind of message every time you commit something: The main differences between Prettier and ESLint are the following:
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-format-code-with-prettier-in-visual-studio-code
Format Code with Prettier in Visual Studio Code: Setup Guide | DigitalOcean
August 1, 2025 - This ensures that all team members (and CI systems) use the same Prettier version. Include a script that lets contributors format all code consistently from the command line: ... Now, anyone can run npm run format to apply Prettier formatting project-wide.
Find elsewhere
🌐
Azz
azz.github.io › prettier › docs › en › usage.html
Usage · Prettier
Run it without any arguments to see the options. To format a file in-place, use --write. You may want to consider committing your code before doing that, just in case. ... Don't forget the quotes around the globs! The quotes make sure that Prettier expands the globs rather than your shell, ...
🌐
Visual Studio Marketplace
marketplace.visualstudio.com › items
Prettier - Code formatter - Visual Studio Marketplace
January 21, 2026 - Extension for Visual Studio Code - Code formatter using prettier
🌐
GitHub
gist.github.com › Mohamed3on › 840b34ecb7e9abf06ace035183b7f1fc
Run prettier on all JS files in a directory · GitHub
Make a .prettierignore file, and add directories you'd like prettier to not format, for example: **/node_modules · Run prettier --write "**/*.js" *Don't forget the quotes.
🌐
Reddit
reddit.com › r/neovim › format your code using prettier without null-ls! just vanilla vim
r/neovim on Reddit: Format your code using prettier without null-ls! Just vanilla vim
June 29, 2023 -

I've been trying to use as neovim as vanilla possible to expand my horizon and one of the coolest and unknown features out here must be the filter (:!) command. Basically, you can (optionally) redirect part of your buffer as stdin to a shell command which writes it back into your buffer!

As an example, this one way how you could format your code using prettier:

:%!npx prettier --stdin-filepath %

Explanation:

  • The % before the ! is the range, ie, which part of your buffer do you want to redirect to the command? % means everything, but you could also say for example :.!npx prettier ... where the . would be just the current line, or make a visual selection and write :'<,'>!npx prettier ....

  • The ! is called filter by the vim docs, it calls a shell command

  • Next comes the command itself, the first part is pretty self explanatory. I don't have prettier installed globally so I use npx. You have to pass the --stdin-filepath option, otherwise it won't read your buffer, but the file content (which can differ from your buffer if, for example, you haven't saved your buffer yet). The second % means, in the context of the shell command, "the current file name". (And another cool trick: you can expand it using <c-a>)

That's it, you can use this with any shell command! The beauty of the unix philosophy...

Of course you could also map this to some keybinding.

If you know other cool and hidden tricks of vim, please share them in the comments!

🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 12336215428882-Run-prettier-as-default-formatter
Run prettier as default formatter – IDEs Support (IntelliJ Platform) | JetBrains
The "prettier" configuration is maybe honoured, but the IDE's formatting always kicks in. For example, I have tab-width 2 in prettier, and IDE has 4 spaces: when I run "prettier -w ." it reverts the formatting of WebStorm :)
🌐
GitHub
github.com › prettier › prettier › issues › 6280
How do I use the CLI to fix all files? · Issue #6280 · prettier/prettier
July 9, 2019 - If I try prettier --check "*" or prettier --check NOTHING then Prettier seems to completely ignore the .prettierignore file.
Author   octogonz
🌐
JetBrains
jetbrains.com › help › idea › prettier.html
Prettier | IntelliJ IDEA Documentation
In the Settings dialog (Ctrl+Alt+S) , go to Languages & Frameworks | JavaScript | Prettier. In the Run for files field, specify the file patterns to which Prettier will be applied automatically when such files are saved or when the Reformat ...
🌐
Fig
fig.io › manual › prettier
prettier [file, dir or glob...] | Fig
Run Prettier from the command line · On this page · Arguments · Options ·
🌐
Medium
medium.com › better-programming › run-your-prettier-scripts-even-faster-ef85381cf28e
Run Your Prettier Scripts Even Faster | by Nerea Leguinazabal | Better Programming
September 26, 2022 - We are now ready to initialize a server in our terminal with the following command: # initializes the server node node_modules/prettier-plugin-apex/bin/start-apex-server.js · Run Prettier with some add-ons with the usual command:
🌐
Codereadability
codereadability.com › automated-code-formatting-with-prettier
Automated code formatting with Prettier
May 10, 2018 - Open the Command Palette (under the View submenu, or using Cmd+Shift+P on Mac and Ctrl+Shift+P on Windows). Then select "Extensions: Install Extensions". Search for "Prettier", click "Install", and then "Reload" once the installation is complete. 2. Run Prettier on a file ·
🌐
Alphr
alphr.com › home › how to use prettier in vs code
How To Use Prettier in VS Code
July 18, 2022 - You may also choose whether or not to include semi-colons. Here’s how to configure the Prettier settings on VS Code. Go to Settings by clicking “Command + ,(comma)” if you are using a Mac or “Control + ,(comma)” for Windows.