TO START:

Its helpful to know which "settings.json" your configuring. You need to make sure that both your workspace ".vscode/settings.json" file, and your user "settings.json" file (path is contingent on the O.S. your running) are configured to work harmoniously, and that one is not overriding the other with the same configuration twice.

SECONDLY

Remove all configurations you added to your "./settings.json" file for prettier. Those settings were added by the extension author. Despite the esbenp.prettier-vscode being the official prettier extension for VS Code, Prettier was never intended to be configured via VS Code's configuration files. Prettier is very nit-picky about its "./.prettierrc" configuration file. When we use the VS Code config ("settings.json") when attempt to use a prettier config that the extension generates somewhere. If you end up with settings in some project workspace vscode configurations (e.g. ".vscode/settings.json" files) the extension will try to regenerate a file each time one loads a prettier setting. It may even try to load multiple, depending on the scope of your settings.json file. Some how it has to handle that the user-scoped settings.json file should always be overriden by a workspace "settings.json" configuration file. That's not to mention that prettier configs often contain there own overridden rule sets within the ".prettierrc" configuration file.

  • Note: Just FYI, the most problematic configuration your using is the "prettier.configPath" setting.

_I'm going to stop going down the rabbit hole, hopefully you get the point I am making, which is: Don't use VS Code settings.json configuration files to configure "Prettier".


This will be more easy to explain with a bullet-list

The following will help you configure a clean environment, one where Prettier will work as you have configure it to work.

To start...

  1. ...delete all Prettier settings that you added to all settings.json files. This includes any Prettier settings you added to project ".vscode/settings.json" files, and it especially includes all Prettier-settings that you added to your user "settings.json" file. After you finish, reload VS Code, by closing it out completely, and reopening it.


  1. Rather than delete all prettier configuration files from any projects you have open, I am going to instead ask that when you reopen VS Code, that you only open one instance of VS Code. If VS Code opens a project (aka project-folder) after restarting, you're going to want to close that project w/o opening another one. To do that you can...
    • Use the keybinding ALT + K followed by the F key.
    • Alternatively you can use the title-bar menu like so: FILE  >>  CLOSE FOLDER

Additionally, make sure all tabs are closed as well.



  1. At this point your instance of VS Code should be totally empty, completely a blank canvas. From here you are going to want to create a new file. To do this...

    • You have one of two options

      • (A) You can use the keybinding CTRL + ALT + SUPER + N
      • (B) Another way to achieve the same thing is to use the title-bar menu like so:   FILE  >>  NEW FILE
    • Once you've prompted VS Code to create a new file VS Code will want you to pick a location where it's to be created at. The location doesn't matter, so long as it is in a completely empty file, with nothing else in it. To name the file, VS Code will probably use the drop-down that is often refereed to as the quick input menu. The file needs to be a JavaScript file, as a consequence, the file must end with the file extension ".js". So I can reference the file later, I will call mine "main.js", but you can call your whatever you want, so long as you know which file I am referencing when you read "main.js".

    • In the same folder as "main.js", create one more new file without a file extension. This file MUST HAVE THE NAME...

    • .prettierrc

NOTE: "The file has a period (or dot) as the first character in its name (this makes it a hidden file)."



  1. Add the following prettier configuration to the ".prettierrc" file you just created.
Copy{
  "trailingComma": "es5",
  "tabWidth": 4,
  "semi": true,
  "singleQuote": true
}


  1. **Execute the following commands"
    1. Copy $ npm init
      
      • The command will ask a bunch of questions, just press enter for each one to quickly configure the environment with the default npm/Node.js configuration.
      • The purpose of this is simply to create a valid "package.json" file.
    2. Copy   $ sudo npm i -g prettier && npm i -D prettier
      
         // Or you can execute it as two commands, like this:
      
         $ sudo npm i -g prettier
         $ npm i -D prettier
      
      • The command (or commands, depending on how you enter them) install prettier as a project dependency, and as a global Node.js package.

NOTE: "Make sure that you have prettier installed as a vscode extension. And make sure that you have only one prettier extension. Having multiple can create problems and confusion. The one you should have should have the Extension ID: esbenp.prettier-vscode "



  1. Prettier Should work now. Use the main.js file we created early to write some javascript, then press F1 to open the quick input, type the word "format document", until you see the option "Format Document", which you want to click. Then choose prettier from the menu. Prettier won't format if you have erroneous code, it needs to be free from error. (if you want to fix errors use a linter like ESLint).

You can add a bunch of blank lines, or put braces on the wrong line, leave out semi colons, and prettier should format all of those mistakes.




Answer from JAYD3V on Stack Overflow
🌐
GitHub
github.com › prettier › prettier-vscode › issues › 3436
Invalid Version · Issue #3436 · prettier/prettier-vscode
June 18, 2024 - ["ERROR" - 1:52:51 PM] Error handling text editor change ["ERROR" - 1:52:51 PM] Invalid Version: [object Object] TypeError: Invalid Version: [object Object] at new SemVer (d:\workspace\project*\node_modules\prettier\index.js:2461:13) at compare (d:\workspace\project*\node_modules\prettier\index.js:2818:12) at Function.gte (d:\workspace\project*\node_modules\prettier\index.js:2884:12) at filterSince (d:\workspace\project*\node_modules\prettier\index.js:4321:82) at Array.filter () at getSupportInfo (d:\workspace\project*\node_modules\prettier\index.js:4254:6) at Object.getSupportInfo (d:\workspa
Author   busyhe
🌐
GitHub
github.com › prettier › prettier-vscode › issues › 1892
Value is not accepted in VSCode settings · Issue #1892 · prettier/prettier-vscode
April 11, 2021 - setup defaultFormatter in settings ("editor.defaultFormatter": "esbenp.prettier-vscode") File settings.json valid · File settings.json has invalid property · VS Code Version: March 2021 (version 1.55) - 1.55.1 · Prettier Extension Version: 6.3.2 · OS and version: MacOS Big Sur 11.2.3 ·
Author   dmatis2
Discussions

prettier 3.0 and prettier-vscode v10.1.0 won't load plugins
Summary In my project, VS Code successfully loads my Prettier config, but when I try and format a tsx file it logs an error. Visual Studio Code is on version 1.80.2. My config is as follows, and is exported as a package in a monorepo and... More on github.com
🌐 github.com
37
August 1, 2023
Prettier VSCode Not Consistent With CLI
Is there a way to update the version of prettier used within the VSCode extension or force it to use the same globally installed version? Reading the FAQ on the extension page it seems it should be using 3.0.0 as the extension is past version 10. ... ["INFO" - 3:21:29 PM] Extension Name: esbenp.p... More on github.com
🌐 github.com
16
June 17, 2024
Invalid prettier configuration file detected in VS Code
Booted up my VM running xubuntu in vmware workstation 17 pro. Started working on an exercise in the Odin project in VS Code, beforehand, updated and upgraded via sudo apt-get update and upgrade. St... More on stackoverflow.com
🌐 stackoverflow.com
Prettier throws error about invalid version - log is a very unhelpful `Invalid Version: [object Object]`
Summary I have prettier installed in VS Code extension version is 11 I have prettier installed via NPM version is 1.19.1 When I navigate around in my files the extension throws an error, and format... More on github.com
🌐 github.com
3
December 3, 2024
🌐
DEV Community
dev.to › dmytrych › fixing-prettier-not-working-with-vscode-44ml
Fixing Prettier not working with VSCode - DEV Community
June 9, 2023 - Try disabling other VSCode extensions. Conflicting extensions can interfere with Prettier. Newer versions of VSCode extensions may not support older versions of Prettier.
🌐
GitHub
github.com › prettier › prettier-vscode › issues › 3104
prettier 3.0 and prettier-vscode v10.1.0 won't load plugins · Issue #3104 · prettier/prettier-vscode
August 1, 2023 - Summary In my project, VS Code successfully loads my Prettier config, but when I try and format a tsx file it logs an error. Visual Studio Code is on version 1.80.2. My config is as follows, and is exported as a package in a monorepo and...
Author   lewisflude
🌐
GitHub
github.com › prettier › prettier-vscode › issues › 3431
Prettier VSCode Not Consistent With CLI · Issue #3431 · prettier/prettier-vscode
June 17, 2024 - Is there a way to update the version of prettier used within the VSCode extension or force it to use the same globally installed version? Reading the FAQ on the extension page it seems it should be using 3.0.0 as the extension is past version 10. ... ["INFO" - 3:21:29 PM] Extension Name: esbenp.p...
Author   hamirmahal
🌐
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
Top answer
1 of 6
20

TO START:

Its helpful to know which "settings.json" your configuring. You need to make sure that both your workspace ".vscode/settings.json" file, and your user "settings.json" file (path is contingent on the O.S. your running) are configured to work harmoniously, and that one is not overriding the other with the same configuration twice.

SECONDLY

Remove all configurations you added to your "./settings.json" file for prettier. Those settings were added by the extension author. Despite the esbenp.prettier-vscode being the official prettier extension for VS Code, Prettier was never intended to be configured via VS Code's configuration files. Prettier is very nit-picky about its "./.prettierrc" configuration file. When we use the VS Code config ("settings.json") when attempt to use a prettier config that the extension generates somewhere. If you end up with settings in some project workspace vscode configurations (e.g. ".vscode/settings.json" files) the extension will try to regenerate a file each time one loads a prettier setting. It may even try to load multiple, depending on the scope of your settings.json file. Some how it has to handle that the user-scoped settings.json file should always be overriden by a workspace "settings.json" configuration file. That's not to mention that prettier configs often contain there own overridden rule sets within the ".prettierrc" configuration file.

  • Note: Just FYI, the most problematic configuration your using is the "prettier.configPath" setting.

_I'm going to stop going down the rabbit hole, hopefully you get the point I am making, which is: Don't use VS Code settings.json configuration files to configure "Prettier".


This will be more easy to explain with a bullet-list

The following will help you configure a clean environment, one where Prettier will work as you have configure it to work.

To start...

  1. ...delete all Prettier settings that you added to all settings.json files. This includes any Prettier settings you added to project ".vscode/settings.json" files, and it especially includes all Prettier-settings that you added to your user "settings.json" file. After you finish, reload VS Code, by closing it out completely, and reopening it.


  1. Rather than delete all prettier configuration files from any projects you have open, I am going to instead ask that when you reopen VS Code, that you only open one instance of VS Code. If VS Code opens a project (aka project-folder) after restarting, you're going to want to close that project w/o opening another one. To do that you can...
    • Use the keybinding ALT + K followed by the F key.
    • Alternatively you can use the title-bar menu like so: FILE  >>  CLOSE FOLDER

Additionally, make sure all tabs are closed as well.



  1. At this point your instance of VS Code should be totally empty, completely a blank canvas. From here you are going to want to create a new file. To do this...

    • You have one of two options

      • (A) You can use the keybinding CTRL + ALT + SUPER + N
      • (B) Another way to achieve the same thing is to use the title-bar menu like so:   FILE  >>  NEW FILE
    • Once you've prompted VS Code to create a new file VS Code will want you to pick a location where it's to be created at. The location doesn't matter, so long as it is in a completely empty file, with nothing else in it. To name the file, VS Code will probably use the drop-down that is often refereed to as the quick input menu. The file needs to be a JavaScript file, as a consequence, the file must end with the file extension ".js". So I can reference the file later, I will call mine "main.js", but you can call your whatever you want, so long as you know which file I am referencing when you read "main.js".

    • In the same folder as "main.js", create one more new file without a file extension. This file MUST HAVE THE NAME...

    • .prettierrc

NOTE: "The file has a period (or dot) as the first character in its name (this makes it a hidden file)."



  1. Add the following prettier configuration to the ".prettierrc" file you just created.
Copy{
  "trailingComma": "es5",
  "tabWidth": 4,
  "semi": true,
  "singleQuote": true
}


  1. **Execute the following commands"
    1. Copy $ npm init
      
      • The command will ask a bunch of questions, just press enter for each one to quickly configure the environment with the default npm/Node.js configuration.
      • The purpose of this is simply to create a valid "package.json" file.
    2. Copy   $ sudo npm i -g prettier && npm i -D prettier
      
         // Or you can execute it as two commands, like this:
      
         $ sudo npm i -g prettier
         $ npm i -D prettier
      
      • The command (or commands, depending on how you enter them) install prettier as a project dependency, and as a global Node.js package.

NOTE: "Make sure that you have prettier installed as a vscode extension. And make sure that you have only one prettier extension. Having multiple can create problems and confusion. The one you should have should have the Extension ID: esbenp.prettier-vscode "



  1. Prettier Should work now. Use the main.js file we created early to write some javascript, then press F1 to open the quick input, type the word "format document", until you see the option "Format Document", which you want to click. Then choose prettier from the menu. Prettier won't format if you have erroneous code, it needs to be free from error. (if you want to fix errors use a linter like ESLint).

You can add a bunch of blank lines, or put braces on the wrong line, leave out semi colons, and prettier should format all of those mistakes.




2 of 6
3

After creating a new .prettierrc.json file in a NextJS project and attempting to configure Prettier via .vscode/settings.json (with the Prettier VSCode extension running), I also kept running into Prettier Output errors.

I updated my .vscode/settings.json file to {}, and like the above comment, Prettier now works as expected.

Find elsewhere
🌐
GitHub
github.com › prettier › prettier-vscode › issues › 3585
Prettier throws error about invalid version - log is a very unhelpful `Invalid Version: [object Object]` · Issue #3585 · prettier/prettier-vscode
December 3, 2024 - Prettier throws error about invalid version - log is a very unhelpful Invalid Version: [object Object]#3585 ... I have prettier installed in VS Code extension version is 11 I have prettier installed via NPM version is 1.19.1 When I navigate around in my files the extension throws an error, and formatting is inconsistent, sometimes it follows the repo configuration file, other times it uses its own defaults.
Author   bnm12
🌐
GitHub
github.com › prettier › prettier-vscode › issues › 3631
esbenp.prettier-vscode formats more than needed by normal prettier · Issue #3631 · prettier/prettier-vscode
December 26, 2024 - Version: 1.97.2 (system setup) Commit: e54c774e0add60467559eb0d1e229c6452cf8447 Date: 2025-02-12T23:20:35.343Z Electron: 32.2.7 ElectronBuildId: 10982180 Chromium: 128.0.6613.186 Node.js: 20.18.1 V8: 12.8.374.38-electron.0 OS: Windows_NT x64 10.0.26100 ... ["INFO" - 1:09:09 PM] Formatting file://projectfolder/test.ts ["INFO" - 1:09:09 PM] Using config file at projectfolder/.prettierrc ["INFO" - 1:09:09 PM] PrettierInstance: { "modulePath": "projectfolder/node_modules/prettier/index.cjs", "messageResolvers": {}, "version": "3.4.2" } ["INFO" - 1:09:09 PM] Using ignore file (if present) at projectfolder/.prettierignore ["INFO" - 1:09:09 PM] File Info: { "ignored": false, "inferredParser": "typescript" } ["INFO" - 1:09:09 PM] Detected local configuration (i.e.
Author   sebbi08
🌐
GitHub
github.com › prettier › prettier-vscode › issues › 3071
Prettier does not format documents in latest Prettier + VS code versions · Issue #3071 · prettier/prettier-vscode
May 25, 2023 - If you have prettier or plugins referenced in package.json, ensure you have run `npm install` ["ERROR" - 10:51:46 AM] Cannot find Prettier package.json Error: Cannot find Prettier package.json at t.ModuleResolver.loadPrettierVersionFromPackageJson (/home/omer/.vscode-server/extensions/esbenp.prettier-vscode-9.19.0/dist/extension.js:1:3996) at t.ModuleResolver.getPrettierInstance (/home/omer/.vscode-server/extensions/esbenp.prettier-vscode-9.19.0/dist/extension.js:1:5305) at t.ModuleResolver.getResolvedConfig (/home/omer/.vscode-server/extensions/esbenp.prettier-vscode-9.19.0/dist/extension.js:
Author   OmerMessing
🌐
GitHub
github.com › prettier › prettier-vscode › issues › 3438
`esbenp.prettier-vscode` isn't consistent with `prettier` in `package.json` · Issue #3438 · prettier/prettier-vscode
June 19, 2024 - esbenp.prettier-vscode should format *.config.ts and test/ui/**.spec.ts files exactly as ... Version: 1.90.1 Commit: 611f9bfce64f25108829dd295f54a6894e87339d Date: 2024-06-11T21:02:43.666Z Electron: 29.4.0 ElectronBuildId: 9593362 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Linux x64 6.5.0-41-generic snap
Author   hamirmahal
🌐
Reddit
reddit.com › r/vscode › why my vs code pettier not working ?
r/vscode on Reddit: Why my VS code pettier not working ?
March 13, 2021 -

I have been searching google for several hours.

Many user have similar problem with me. https://stackoverflow.com/questions/52586965/why-does-prettier-does-not-format-code-in-vs-code/64273353#64273353

But none of the solution works for me.

https://imgur.com/2ssn1Vt

I have prettier installed. And I have tried the following

1.Command + Shift + p

2.type format document with

3.select Configure Default Formatter...

https://imgur.com/xw5oYvS

Then I cant select Prettier as default.

I only give me Python(default) as the only option.

I have a setting.json inside my root. Is it related?

https://imgur.com/KbEdsOV

🌐
GitHub
github.com › prettier › prettier › issues › 15092
Extension 'Prettier - Code formatter' is configured as formatter but it cannot format 'Ruby'-files · Issue #15092 · prettier/prettier
July 13, 2023 - cd esbenp.prettier-vscode-9.19.0-universal npm install --save-dev prettier @prettier/plugin-ruby npm WARN idealTree Removing dependencies.prettier in favor of devDependencies.prettier npm WARN deprecated vsce@2.15.0: vsce has been renamed to @vscode/vsce. Install using @vscode/vsce instead.
Author   hgw77
🌐
Stack Overflow
stackoverflow.com › questions › 79169522 › i-cant-get-prettiereslint-to-work-with-typescript-projects-in-vscode
I can't get prettier+eslint to work with TypeScript projects in VSCode - Stack Overflow
https://github.com/idahogurl/vs-code-prettier-eslint ... ["ERROR" - 9:45:51 PM] Invalid version Error: Invalid version at t.isAboveV3 (c:\Users\ken\.vscode\extensions\esbenp.prettier-vscode-11.0.0\dist\extension.js:1:25515) at t.default.getSelectors (c:\Users\ken\.vscode\extensions\esbenp.prettier-vscode-11.0.0\dist\extension.js:1:11796) at t.default.handleActiveTextEditorChanged (c:\Users\ken\.vscode\extensions\esbenp.prettier-vscode-11.0.0\dist\extension.js:1:11123) at processTicksAndRejections (node:internal/process/task_queues:95:5)```
🌐
GitHub
github.com › prettier › prettier-vscode › issues › 3445
`this.prettierModule.resolveConfigFile is not a function` error when formatting · Issue #3445 · prettier/prettier-vscode
June 24, 2024 - ["INFO" - 11:47:03 AM] Extension Version: 10.4.0. ["ERROR" - 11:47:03 AM] Error handling text editor change ["ERROR" - 11:47:03 AM] Failed to load Prettier instance: /Users/user/.nvm/versions/node/v18.19.0/bin/prettier Error: Failed to load Prettier instance: /Users/user/.nvm/versions/node/v18.19.0/bin/prettier at t.PrettierMainThreadInstance.import (/Users/user/.vscode/extensions/esbenp.prettier-vscode-10.4.0/dist/extension.js:1:18055) at t.ModuleResolver.getPrettierInstance (/Users/user/.vscode/extensions/esbenp.prettier-vscode-10.4.0/dist/extension.js:1:5771) at t.default.handleActiveTextEd
Author   yuemin-hu-20231024
🌐
GitHub
github.com › prettier › prettier-vscode › issues › 3475
Unexpectedly resolving globally installed prettier version · Issue #3475 · prettier/prettier-vscode
July 22, 2024 - Add the following to that file, {"dependencies": {"prettier": "2.2.3"}}. The file just needs to exist, the version doesn't matter. Restart VSCode.
Author   aramissennyeydd
🌐
GitHub
github.com › prettier › prettier-vscode › issues › 2047
Prettier does not work as default formatter in VS Code 1.57.1 on Windows. · Issue #2047 · prettier/prettier-vscode
June 29, 2021 - { "editor.formatOnPaste": true, "editor.formatOnSave": true, "editor.defaultFormatter": "esbenp.prettier-vscode" } Manually formatting doesn't work either. Running prettier in the command line does correctly format the file. Short summary of what is going on or to provide context.
Author   KerimG