Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

9.16 fails to load from custom prettierPath #3041

Closed
vsiao opened this issue Jun 23, 2023 · 19 comments · Fixed by #3042
Closed

9.16 fails to load from custom prettierPath #3041

vsiao opened this issue Jun 23, 2023 · 19 comments · Fixed by #3042
Labels
locked Please open a new issue and fill out the template instead of commenting.

Comments

@vsiao
Copy link
Contributor

vsiao commented Jun 23, 2023

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 #3038 (comment). 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)
@tobz1000
Copy link

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

@spencermefford
Copy link

Rolling back to 9.14.0 works for me.

@azat-io
Copy link

azat-io commented Jun 23, 2023

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

@vsiao
Copy link
Contributor Author

vsiao commented Jun 23, 2023

https://stackoverflow.com/a/53755378

image

@Hibrix-net
Copy link

Hibrix-net commented Jun 27, 2023

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

@Connorelsea
Copy link

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

@Hibrix-net
Copy link

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

I'm not sure why they kind of ignore it...

@vsiao
Copy link
Contributor Author

vsiao commented Jul 5, 2023

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.

@Hibrix-net
Copy link

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.

@FNGR2911
Copy link

FNGR2911 commented Jul 10, 2023

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

@zzeni
Copy link

zzeni commented Jul 11, 2023

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.

@madhavpcm
Copy link

In arch linux, 9.14.0 was spitting out another error, 9.15.0 works.

@azat-io
Copy link

azat-io commented Jul 21, 2023

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)

@Shimodos
Copy link

Shimodos commented Sep 4, 2023

For Windows users
If you use NVM with different versions of NODE
1.npm i prettier -g
2. in my case, go to the folder with the NODE version C:\Users\admin\AppData\Roaming\nvm\v18.16.0\node_modules
it was installed here prettier
3. copy the prettier folder
4. transfer it to C:\Users\admin\AppData\Roaming\nvm\v18.16.0\node_modules\npm\node_modules
5. Go to VS Code, extension, Prettier : Preettier Path
past C:\Users\admin\AppData\Roaming\nvm\v18.16.0\node_modules\npm\node_modules\prettier
6.reload

https://stackoverflow.com/questions/58866847/in-vs-code-im-getting-this-error-failed-to-load-module-attempted-to-load-pr

@Hibrix-net
Copy link

Still not solved.

@oclero
Copy link

oclero commented Oct 1, 2023

Hi! Still not solved, indeed (macOS)

@edouard-lopez
Copy link

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

@Hibrix-net
Copy link

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

I'm in Windows 10. In my settings.json file I have:

"prettier.prettierPath": "C:\Program Files\nodejs\node_modules\prettier",

Do you mean to change that one? I tried with the path suggested in the StackOverflow question but didn't worked.

Could you please tell me where to change this path?

Manty thanks,

Copy link

github-actions bot commented Jan 3, 2024

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 github-actions bot added the locked Please open a new issue and fill out the template instead of commenting. label Jan 3, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked Please open a new issue and fill out the template instead of commenting.
Projects
None yet
Development

Successfully merging a pull request may close this issue.