Closed OmerMessing closed 1 week ago
I am getting the same issue. I rollback to the previous version to resolve it for me. Install previous versions
Yes, for me using the MacOS version of VSCode, the last version of prettier that still works was 9.15.0.
0.9.18
works for me, 0.9.19
not.
Why: https://github.com/prettier/prettier-vscode/commit/f6ff18b500858b913ef43dbad73ecbae929c3b27
I revert this (again, in the dist js file) and it works
Confirmation here
Same problem and has been for a very long time
Just ran into this as well on extension version v9.19.0
. Whether or not prettier.prettierPath
is set in VSCode's settings.json
didn't make a difference. Reverting to v9.18.0
resolved it.
For info:
Seems like even reverting to an older version does not fix prettier not working when installed via Yarn PnP
Same issue. Getting "Invalid prettier configuration file detected." in the log. Works fine with Prettier 2.8.8.
Same issue.
["ERROR" - 17:08:46] Invalid prettier configuration file detected.
UPDATE: Resolved. Was because I had a require
for a plugin in the config which wasn't valid anymore.
Prettier hasn't worked for over a month now
Any progress with this issue? I'm also seeing it since about a month ago.
I have the prettier.prettierPath
option pointing to the global node_modules
as the extension won't otherwise load the globally installed plugins (we're using prettier-plugin-java
).
We have many projects that don't use JavaScript and don't contain a node_modules
directory.
Downgrading to 9.15.0 will fix the problem. Starting from 9.16.0 the module fails to load with the following messages:
["INFO" - 12:50:47 AM] Extension Name: esbenp.prettier-vscode.
["INFO" - 12:50:47 AM] Extension Version: 9.16.0.
["INFO" - 12:50:47 AM] Attempted to load Prettier module from /usr/lib/node_modules/prettier
["ERROR" - 12:50:47 AM] Failed to load module. If you have prettier or plugins referenced in package.json, ensure you have run `npm install`
["ERROR" - 12:50:47 AM] Cannot find Prettier package.json
Error: Cannot find Prettier package.json
at t.ModuleResolver.loadPrettierVersionFromPackageJson (/root/.vscode-server/extensions/esbenp.prettier-vscode-9.16.0/dist/extension.js:1:3631)
at t.ModuleResolver.getPrettierInstance (/root/.vscode-server/extensions/esbenp.prettier-vscode-9.16.0/dist/extension.js:1:5025)
at t.default.handleActiveTextEditorChanged (/root/.vscode-server/extensions/esbenp.prettier-vscode-9.16.0/dist/extension.js:1:10626)
at t.default.handleActiveTextEditorChangedSync (/root/.vscode-server/extensions/esbenp.prettier-vscode-9.16.0/dist/extension.js:1:10228)
at t.default.registerDisposables (/root/.vscode-server/extensions/esbenp.prettier-vscode-9.16.0/dist/extension.js:1:13071)
at /root/.vscode-server/extensions/esbenp.prettier-vscode-9.16.0/dist/extension.js:1:81163
at processTicksAndRejections (node:internal/process/task_queues:96:5)
With the newer versions, removing prettier.prettierPath
will fix this error, but the Java plugin won't load, no matter what I do.
I was having the same issue and had to downgrade to 9.15.0. But this workaround fixed the issue for me (I'm on prettier 2.x) and now I'm able to use the latest plugin version.
Apparently no downgrade will make it work with 3.0.3,...
I'm using prettier 3.0.0 and none of the version of prettier-vscode has worked.
if your config file is named prettier.config.js
try renaming it to .prettierrc.cjs
and update the contents to use commonjs (might not even be necessary):
/** @type {import("prettier").Config} */
const config = {
singleQuote: true,
trailingComma: "all",
plugins: ["prettier-plugin-tailwindcss"],
tailwindConfig: "./tailwind.config.js",
};
module.exports = config;
looks like something with the module type parsing is messed up.
The same problem
The only 'workaround' for me is running Prettier over CLI before creating a PR:
"scripts": {
"format": "npx prettier . --write",
},
It's not a solution whatsoever, it just the only thing I think to get my documents formatted.
After updating some dependencies on my project, Prettier stopped formatting .vue
files through VSCode.
But it was still running OK from the CLI.
I tried the solution from @kitsunekyo, and found out that this was the line causing the issue:
module.exports = {
plugins: [require('prettier-plugin-tailwindcss')],
// ...
}
Changing that to this solved the issue for me:
module.exports = {
plugins: ['prettier-plugin-tailwindcss'],
// ...
}
It was logging out Invalid prettier configuration file detected. See log for details.
.
Everything is good now. :pray:
This issue has been labeled as stale due to inactivity. Reply to keep this issue open.
Still monitoring.
On Thu, Dec 7, 2023 at 8:51 PM github-actions[bot] @.***> wrote:
This issue has been labeled as stale due to inactivity. Reply to keep this issue open.
— Reply to this email directly, view it on GitHub https://github.com/prettier/prettier-vscode/issues/3071#issuecomment-1846433127, or unsubscribe https://github.com/notifications/unsubscribe-auth/BBO4GJQXG4UHMFULVR5WKJ3YIJXBLAVCNFSM6AAAAAA2EFESYWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBWGQZTGMJSG4 . You are receiving this because you are subscribed to this thread.Message ID: @.***>
if your config file is named
prettier.config.js
try renaming it to.prettierrc.cjs
and update the contents to use commonjs (might not even be necessary):
/** @type {import("prettier").Config} */ const config = { singleQuote: true, trailingComma: "all", plugins: ["prettier-plugin-tailwindcss"], tailwindConfig: "./tailwind.config.js", }; module.exports = config;
looks like something with the module type parsing is messed up.
this answer saved my life and my job!!
What fixed it for me was adding this to VS Code settings:
"prettier.prettierPath": "./node_modules/prettier/index.js"
This issue has been labeled as stale due to inactivity. Reply to keep this issue open.
I encountered this issue when I synchronized my VSCode settings on another computer; the Prettier extension was referencing a different path. Correcting the 'prettier.prettierPath' setting resolved the problem for me.
Summary
Prettier does not format code, error and logs shown below.
Using: Ubuntu: 22.04.2 in Windows + WSL 2 VS Code: 1.80.0 Prettier: 9.19.0
Github Repository to Reproduce Issue
Installed the latest prettier vs-code extension.
Steps To Reproduce:
Expected result
Document should be formatted.
Actual result
Document is not formatted.
Additional information
I updated to the latest prettier extension + regular vs code update and it just stopped working.
VS Code Version:
Version: 1.80.0 (user setup) Commit: 660393deaaa6d1996740ff4880f1bad43768c814 Date: 2023-07-04T15:06:02.407Z Electron: 22.3.14 ElectronBuildId: 21893604 Chromium: 108.0.5359.215 Node.js: 16.17.1 V8: 10.8.168.25-electron.0 OS: Windows_NT x64 10.0.19044
Prettier Extension Version:
Prettier: 9.19.0
OS and version:
Windows 10 Pro Version 21H2
Prettier Log Output