Prettier pluguin doesn't work with vscode 1.79.0 - error "cannot read properties of undefined (reading 'uid')"
Summary
Prettier plugin doesn't work with vscode 1.79.0 (before update it worked fine)
Steps To Reproduce:
Run format
Expected result
Document should be formatted
Actual result
Document not formatted, error shown in terminal prettier output
Additional information
Repository is monorepo
Versions:
- prettier: 2.8.8
- prettier vscode: 9.13.0
- vscode: 1.79.0
- windows 11 wsl
Prettier Log Output
Error:
["ERROR" - 12:05:24 AM] Failed to load module. If you have prettier or plugins referenced in package.json, ensure you have run `npm install`
["ERROR" - 12:05:24 AM] Cannot read properties of undefined (reading 'uid')
TypeError: Cannot read properties of undefined (reading 'uid')
at Object.statSync (/home/ziimakc/.vscode-server/bin/b380da4ef1ee00e224a15c1d4d9793e27c2b6302/node_modules/graceful-fs/polyfills.js:313:17)
at p (/home/ziimakc/.vscode-server/extensions/esbenp.prettier-vscode-9.13.0/dist/extension.js:1:35221)
at L (/home/ziimakc/.vscode-server/extensions/esbenp.prettier-vscode-9.13.0/dist/extension.js:1:37052)
at /home/ziimakc/.vscode-server/extensions/esbenp.prettier-vscode-9.13.0/dist/extension.js:1:36677
at Function.e.exports [as sync] (/home/ziimakc/.vscode-server/extensions/esbenp.prettier-vscode-9.13.0/dist/extension.js:1:36723)
at t.ModuleResolver.findPkg (/home/ziimakc/.vscode-server/extensions/esbenp.prettier-vscode-9.13.0/dist/extension.js:1:7297)
at t.ModuleResolver.getPrettierInstance (/home/ziimakc/.vscode-server/extensions/esbenp.prettier-vscode-9.13.0/dist/extension.js:1:3251)
at t.default.format (/home/ziimakc/.vscode-server/extensions/esbenp.prettier-vscode-9.13.0/dist/extension.js:1:13495)
at async t.PrettierEditProvider.provideEdits (/home/ziimakc/.vscode-server/extensions/esbenp.prettier-vscode-9.13.0/dist/extension.js:1:11367)
at async U.provideDocumentFormattingEdits (/home/ziimakc/.vscode-server/bin/b380da4ef1ee00e224a15c1d4d9793e27c2b6302/out/vs/workbench/api/node/extensionHostProcess.js:102:45790)
["ERROR" - 12:05:24 AM] Prettier could not be loaded. See previous logs for more information.
Related #3000
Quick fix, add to project settings in .vscode/settings.json
"prettier.prettierPath": "./node_modules/prettier"
Having the same problem. If the project I'm working on has prettier installed as a dependency, the plugin fails an throws the same error as OP.
The fix suggested in https://github.com/prettier/prettier-vscode/issues/3019#issuecomment-1583356998 solves the problem.
Related #3000
Quick fix, add to project settings in
.vscode/settings.json"prettier.prettierPath": "./node_modules/prettier"
This does't work for me. I still get the same error.
I do have my project in a sub-directory, so I changed the path accordingly.
@szszoke Make sure you're changing prettierPath not prettierConfigPath, very similar names, I made that mistake a sec ago.
@szszoke Make sure you're changing
prettierPathnotprettierConfigPath, very similar names, I made that mistake a sec ago.
No worries! I just downgraded VS Code until this is resolved.
@szszoke Make sure you're changing
prettierPathnotprettierConfigPath, very similar names, I made that mistake a sec ago.No worries! I just downgraded VS Code until this is resolved.
for me, it work, on vscode settings on workSpaces.
{
"prettier.prettierPath": "./node_modules/prettier"
}
@szszoke Make sure you're changing
prettierPathnotprettierConfigPath, very similar names, I made that mistake a sec ago.No worries! I just downgraded VS Code until this is resolved.
for me, it work, on vscode settings on workSpaces.
{ "prettier.prettierPath": "./node_modules/prettier" }
I tested again and it still doesn't work so I downgraded VS Code again.
vs code upgrade to 1.79.1
vs code upgrade to 1.79.1
still have problem,not work
Tested with a recent update, seems to be working after removing the prettierPath workaround.
@luchillo17 VSCode v1.79.2?
FWIW, I just tested with VSCode v1.79.2, this problem still occurred when not using the workaround.
Yes v1.79.2, just restarted my WSL2 instance to make sure it still worked, which version has #3030 in?
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.