prettier-vscode: 9.16 fails to load from custom prettierPath

Summary

In 9.16, when configured with a path to the prettier module (eg. node_modules/prettier), the extension fails to load.

Steps To Reproduce:

Set prettier.prettierPath config to node_modules/prettier

Expected result

Extension loads node_modules/prettier/package.json successfully.

Actual result

Extension fails to load. The extension appears to look for node_modules/packages.json, then package.json, etc.

Additional information

VS Code Version: 1.79.2

Prettier Extension Version: 9.16

OS and version: Mac OS Ventura 13.4

Prettier Log Output

Below trace is from https://github.com/prettier/prettier-vscode/pull/3038#issuecomment-1602659513. cc @mreduar

["INFO" - 1:39:28 PM] Extension Name: esbenp.prettier-vscode.
["INFO" - 1:39:28 PM] Extension Version: 9.16.0.
["INFO" - 1:39:28 PM] Attempted to load Prettier module from /var/www/html/node_modules/prettier
["ERROR" - 1:39:28 PM] Failed to load module. If you have prettier or plugins referenced in package.json, ensure you have run `npm install`
["ERROR" - 1:39:28 PM] Cannot load Prettier version from package.json
Error: Cannot load Prettier version from package.json
    at t.ModuleResolver.loadPrettierVersionFromPackageJson (/root/.vscode-server/extensions/esbenp.prettier-vscode-9.16.0/dist/extension.js:1:3820)
    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)

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 42
  • Comments: 19 (2 by maintainers)

Most upvoted comments

Rolling back to 9.14.0 works for me.

9.19.0 not works.

["INFO" - 14:09:38] Attempted to load Prettier module from /opt/homebrew/bin/prettier
["ERROR" - 14:09:38] Failed to load module. If you have prettier or plugins referenced in package.json, ensure you have run `npm install`
["ERROR" - 14:09:38] Cannot find Prettier package.json
Error: Cannot find Prettier package.json
	at t.ModuleResolver.loadPrettierVersionFromPackageJson (/Users/azat/.vscode/extensions/esbenp.prettier-vscode-9.19.0/dist/extension.js:1:4058)
	at t.ModuleResolver.getPrettierInstance (/Users/azat/.vscode/extensions/esbenp.prettier-vscode-9.19.0/dist/extension.js:1:5367)
	at t.default.handleActiveTextEditorChanged (/Users/azat/.vscode/extensions/esbenp.prettier-vscode-9.19.0/dist/extension.js:1:10771)
	at i.handleActiveTextEditorChangedSync [as value] (/Users/azat/.vscode/extensions/esbenp.prettier-vscode-9.19.0/dist/extension.js:1:10373)
	at p.w (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:60:1902)
	at p.x (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:60:1972)
	at p.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:60:2188)
	at i.value (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:103:16537)
	at p.w (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:60:1902)
	at p.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:60:2119)
	at e.$kL.acceptDocumentsAndEditorsDelta (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:101:13399)
	at e.$kL.$acceptDocumentsAndEditorsDelta (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:101:11770)
	at t.N (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:111:11199)
	at t.M (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:111:10965)
	at t.H (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:111:10046)
	at t.G (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:111:9122)
	at i.value (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:111:7952)
	at p.w (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:60:1902)
	at p.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:60:2119)
	at f.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:76:13931)
	at i.value (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:127:30341)
	at p.w (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:60:1902)
	at p.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:60:2119)
	at f.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:76:13931)
	at MessagePortMain.<anonymous> (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:127:28621)
	at MessagePortMain.emit (node:events:513:28)
	at MessagePortMain.emit (node:domain:489:12)
	at MessagePortMain._internalPort.emit (node:electron/js2c/utility_init:2:367)

This was fixed by d04b294, which is present in v9.18.0, but mistakenly reverted in v9.19.0. Downgrading to v9.18.0 should work for now, while the regression is tracked in #3059.

I suspect I’m not the only one coming across this bug, having just added prettierPath to my config as a workaround for #3019 😄

I solved it using this solution and it’s work with latest extension version https://stackoverflow.com/a/77124000/802365

Hi! Still not solved, indeed (macOS)

@spencermefford How can I roll back VS Code extension version?

Still not solved.

This was fixed by d04b294, which is present in v9.18.0, but mistakenly reverted in v9.19.0. Downgrading to v9.18.0 should work for now, while the regression is tracked in #3059.

Thanks @vsiao , I can confirm that on my MacOS 12.4, versions v9.14.0 and v9.18.0 seem to work fine even without having to set prettierPath in vscode settings (because it defaults to node_modules/prettier). The versions in-between and v9.19.0 though, are unable to load the prettier module and report the error above.

Same here, just 9.14.0 is working… (macOS 13.3.1)

This was fixed by d04b294, which is present in v9.18.0, but mistakenly reverted in v9.19.0. Downgrading to v9.18.0 should work for now, while the regression is tracked in #3059.

The latest working version for me its the 9.14.0 as @spencermefford said. Anything above spits the same error. So not solved for me.

This is still happening for me, downgrading worked. Anybody know why this got closed?

Same is happenning to me but I had to downgrade until 9.10.4 to make it work as before.

See my comments here: #3020