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

this.prettierModule.resolveConfigFile is not a function error when formatting #3445

Open
yuemin-hu-20231024 opened this issue Jun 25, 2024 · 5 comments

Comments

@yuemin-hu-20231024
Copy link

Summary

Prettier files a error message when using 'format document with -> prettier'

Github Repository to Reproduce Issue

Steps To Reproduce:

Prettier files a error message when using 'format document with -> prettier'

Expected result

Describe what should have happened.

Actual result

Here's the log:

👇 when I restarted the editor

["INFO" - 11:47:03 AM] Extension Name: esbenp.prettier-vscode.
["INFO" - 11:47:03 AM] Extension Version: 10.4.0.
["ERROR" - 11:47:03 AM] Error handling text editor change
["ERROR" - 11:47:03 AM] Failed to load Prettier instance: /Users/user/.nvm/versions/node/v18.19.0/bin/prettier
Error: Failed to load Prettier instance: /Users/user/.nvm/versions/node/v18.19.0/bin/prettier
    at t.PrettierMainThreadInstance.import (/Users/user/.vscode/extensions/esbenp.prettier-vscode-10.4.0/dist/extension.js:1:18055)
    at t.ModuleResolver.getPrettierInstance (/Users/user/.vscode/extensions/esbenp.prettier-vscode-10.4.0/dist/extension.js:1:5771)
    at t.default.handleActiveTextEditorChanged (/Users/user/.vscode/extensions/esbenp.prettier-vscode-10.4.0/dist/extension.js:1:10967)
    at t.default.handleActiveTextEditorChangedSync (/Users/user/.vscode/extensions/esbenp.prettier-vscode-10.4.0/dist/extension.js:1:10569)
    at t.default.registerDisposables (/Users/user/.vscode/extensions/esbenp.prettier-vscode-10.4.0/dist/extension.js:1:13735)
    at /Users/user/.vscode/extensions/esbenp.prettier-vscode-10.4.0/dist/extension.js:1:83500

👇when focusing any editor window

["ERROR" - 11:47:17 AM] Error handling text editor change
["ERROR" - 11:47:17 AM] Invalid version
Error: Invalid version
    at t.isAboveV3 (/Users/user/.vscode/extensions/esbenp.prettier-vscode-10.4.0/dist/extension.js:1:24917)
    at t.default.getSelectors (/Users/user/.vscode/extensions/esbenp.prettier-vscode-10.4.0/dist/extension.js:1:11745)
    at t.default.handleActiveTextEditorChanged (/Users/user/.vscode/extensions/esbenp.prettier-vscode-10.4.0/dist/extension.js:1:11131)

👇when trying 'format document with prettier'

["INFO" - 11:48:20 AM] Formatting file:///Users/user/Projects/xxx.tsx
["ERROR" - 11:48:20 AM] Error resolving prettier configuration for /Users/user/Projects/xxx.tsx
["ERROR" - 11:48:20 AM] this.prettierModule.resolveConfigFile is not a function
TypeError: this.prettierModule.resolveConfigFile is not a function
    at t.PrettierMainThreadInstance.resolveConfigFile (/Users/user/.vscode/extensions/esbenp.prettier-vscode-10.4.0/dist/extension.js:1:18684)
    at t.ModuleResolver.resolveConfig (/Users/user/.vscode/extensions/esbenp.prettier-vscode-10.4.0/dist/extension.js:1:6856)
    at t.ModuleResolver.getResolvedConfig (/Users/user/.vscode/extensions/esbenp.prettier-vscode-10.4.0/dist/extension.js:1:7735)
    at t.default.format (/Users/user/.vscode/extensions/esbenp.prettier-vscode-10.4.0/dist/extension.js:1:14767)
    at t.PrettierEditProvider.provideEdits (/Users/user/.vscode/extensions/esbenp.prettier-vscode-10.4.0/dist/extension.js:1:12876)

Additional information

image

VS Code Version: Version: 1.85.2 (Universal)

Prettier Extension Version: 10.4.0

Prettier package version: 3.2.2

Other Libs:
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-prettier": "5.1.3",

OS and version: Mac OS 13.6.3 (22G436)

Prettier Log Output

LOG GOES HERE. DO NOT USE A SCREENSHOT, COPY AND PASTE THE TEXT
@bryanjnelson
Copy link

I am having the same issue. This has started recently. I tried reverting to the previous version, but to no avail. Also of interest, I have other VSCode workspaces in which Prettier is working fine.

@DanielEscorciaOrtiz
Copy link

I am also having this issues in one of my workspaces

["ERROR" - 3:29:58 PM] Error resolving prettier configuration for <file>.ts
["ERROR" - 3:29:58 PM] this.prettierModule.resolveConfigFile is not a function
TypeError: this.prettierModule.resolveConfigFile is not a function
	at t.PrettierMainThreadInstance.resolveConfigFile (<path>/.vscode/extensions/esbenp.prettier-vscode-10.4.0/dist/extension.js:1:18684)
	at t.ModuleResolver.resolveConfig (<path>/.vscode/extensions/esbenp.prettier-vscode-10.4.0/dist/extension.js:1:6856)
	at t.ModuleResolver.getResolvedConfig (<path>/.vscode/extensions/esbenp.prettier-vscode-10.4.0/dist/extension.js:1:7735)
	at async t.default.format (<path>/.vscode/extensions/esbenp.prettier-vscode-10.4.0/dist/extension.js:1:14767)
	at async t.PrettierEditProvider.provideEdits (<path>/.vscode/extensions/esbenp.prettier-vscode-10.4.0/dist/extension.js:1:12876)

But other workspaces are having no issues (yet)

@bryanjnelson
Copy link

bryanjnelson commented Jul 30, 2024

For me the root cause of this was related to this issue found over in Microsoft's vscode-eslint repo. There's a lot at play there, so I'll let the issue speak for itself.

@DanielEscorciaOrtiz
Copy link

I am also having this issues in one of my workspaces

["ERROR" - 3:29:58 PM] Error resolving prettier configuration for <file>.ts
["ERROR" - 3:29:58 PM] this.prettierModule.resolveConfigFile is not a function
TypeError: this.prettierModule.resolveConfigFile is not a function
	at t.PrettierMainThreadInstance.resolveConfigFile (<path>/.vscode/extensions/esbenp.prettier-vscode-10.4.0/dist/extension.js:1:18684)
	at t.ModuleResolver.resolveConfig (<path>/.vscode/extensions/esbenp.prettier-vscode-10.4.0/dist/extension.js:1:6856)
	at t.ModuleResolver.getResolvedConfig (<path>/.vscode/extensions/esbenp.prettier-vscode-10.4.0/dist/extension.js:1:7735)
	at async t.default.format (<path>/.vscode/extensions/esbenp.prettier-vscode-10.4.0/dist/extension.js:1:14767)
	at async t.PrettierEditProvider.provideEdits (<path>/.vscode/extensions/esbenp.prettier-vscode-10.4.0/dist/extension.js:1:12876)

But other workspaces are having no issues (yet)

On my side the issue seems to be solved on its own
Surely an update did it, but is unknown to me if it was from vscode or prettier

@RobinClowers
Copy link

I'm also running into this. I tried disabling the eslint plugin and still had the issue, so I don't think it's related to the issue @bryanjnelson linked. I'm using yarn 4, but I'm not using pnp, which appears to be a key factor in that issue.

Prettier Extension Version: 11.0.0
Prettier package version: 3.3.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants