prettier-vscode icon indicating copy to clipboard operation
prettier-vscode copied to clipboard

Prettier pluguin doesn't work with vscode 1.79.0 - error "cannot read properties of undefined (reading 'uid')"

Open ziimakc opened this issue 3 years ago • 14 comments

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.

ziimakc avatar Jun 08 '23 21:06 ziimakc

Related #3000

Quick fix, add to project settings in .vscode/settings.json

"prettier.prettierPath": "./node_modules/prettier"

ziimakc avatar Jun 08 '23 21:06 ziimakc

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.

runoncedev avatar Jun 08 '23 22:06 runoncedev

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 avatar Jun 09 '23 08:06 szszoke

@szszoke Make sure you're changing prettierPath not prettierConfigPath, very similar names, I made that mistake a sec ago.

luchillo17 avatar Jun 09 '23 16:06 luchillo17

@szszoke Make sure you're changing prettierPath not prettierConfigPath, very similar names, I made that mistake a sec ago.

No worries! I just downgraded VS Code until this is resolved.

szszoke avatar Jun 09 '23 17:06 szszoke

@szszoke Make sure you're changing prettierPath not prettierConfigPath, 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" }

alvIndieDevelop avatar Jun 12 '23 14:06 alvIndieDevelop

@szszoke Make sure you're changing prettierPath not prettierConfigPath, 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.

szszoke avatar Jun 14 '23 09:06 szszoke

vs code upgrade to 1.79.1

xianghongai avatar Jun 15 '23 02:06 xianghongai

vs code upgrade to 1.79.1

still have problem,not work

xylinq avatar Jun 15 '23 02:06 xylinq

Tested with a recent update, seems to be working after removing the prettierPath workaround.

luchillo17 avatar Jun 16 '23 00:06 luchillo17

@luchillo17 VSCode v1.79.2?

sosukesuzuki avatar Jun 16 '23 00:06 sosukesuzuki

FWIW, I just tested with VSCode v1.79.2, this problem still occurred when not using the workaround.

DylanSpOddball avatar Jun 16 '23 01:06 DylanSpOddball

Yes v1.79.2, just restarted my WSL2 instance to make sure it still worked, which version has #3030 in?

luchillo17 avatar Jun 16 '23 01:06 luchillo17

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.

github-actions[bot] avatar Nov 06 '23 00:11 github-actions[bot]