You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Checkout to the correct branch (main branch doesn't have the prettier config).
(Optional) Use volta for install the correct node & yarn version.
Run yarn install.
Open repo in vscode (or run command Developer: Restart Extension Host if it's already opened).
Open src/index.ts.
Run command Format document with... > Prettier - Code formatter.
Expected result
If command yarn prettier . can run via the above workaround (require.resolve or import), prettier-vscode must also run.
Actual result
Command yarn prettier . can run via the above workaround (require.resolve or import) but prettier-vscode can't run.
Prettier Log Output
Log - Error resolve node module
["DEBUG" - 11:25:25 AM] Local prettier module path: d:\Code\issue\prettier-yarn-issue\.yarn\sdks\prettier\index.cjs
["INFO" - 11:25:25 AM] Using config file at d:\Code\issue\prettier-yarn-issue\.prettierrc.cjs
["ERROR" - 11:25:25 AM] Error handling text editor change
["ERROR" - 11:25:25 AM] Error resolve node module 'prettier-plugin-tailwindcss'
Error: Error resolve node module 'prettier-plugin-tailwindcss'
at n (c:\Users\phamhongphuc\.vscode\extensions\esbenp.prettier-vscode-10.4.0\dist\extension.js:1:2718)
at c:\Users\phamhongphuc\.vscode\extensions\esbenp.prettier-vscode-10.4.0\dist\extension.js:1:3068
at Array.map (<anonymous>)
at t.resolveConfigPlugins (c:\Users\phamhongphuc\.vscode\extensions\esbenp.prettier-vscode-10.4.0\dist\extension.js:1:3003)
at t.ModuleResolver.resolveConfig (c:\Users\phamhongphuc\.vscode\extensions\esbenp.prettier-vscode-10.4.0\dist\extension.js:1:7485)
at t.default.getSelectors (c:\Users\phamhongphuc\.vscode\extensions\esbenp.prettier-vscode-10.4.0\dist\extension.js:1:11766)
at t.default.handleActiveTextEditorChanged (c:\Users\phamhongphuc\.vscode\extensions\esbenp.prettier-vscode-10.4.0\dist\extension.js:1:11120)
Log - Cannot find package 'prettier' imported from
["DEBUG" - 11:43:54 AM] Local prettier module path: d:\Code\issue\prettier-yarn-issue\.yarn\sdks\prettier\index.cjs
["INFO" - 11:43:54 AM] Using config file at d:\Code\issue\prettier-yarn-issue\.prettierrc.cjs
["ERROR" - 11:43:54 AM] Error handling text editor change
["ERROR" - 11:43:54 AM] Cannot find package 'prettier' imported from d:\Code\issue\prettier-yarn-issue\.yarn\__virtual__\prettier-plugin-tailwindcss-virtual-8449e33aeb\0\cache\prettier-plugin-tailwindcss-npm-0.5.14-4c72a3a392-10.zip\node_modules\prettier-plugin-tailwindcss\dist\index.mjs
Did you mean to import prettier-yarn-issue/.yarn/unplugged/prettier-npm-3.2.5-6859110d6a/node_modules/prettier/plugins/angular.js?
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'prettier' imported from d:\Code\issue\prettier-yarn-issue\.yarn\__virtual__\prettier-plugin-tailwindcss-virtual-8449e33aeb\0\cache\prettier-plugin-tailwindcss-npm-0.5.14-4c72a3a392-10.zip\node_modules\prettier-plugin-tailwindcss\dist\index.mjs
Did you mean to import prettier-yarn-issue/.yarn/unplugged/prettier-npm-3.2.5-6859110d6a/node_modules/prettier/plugins/angular.js?
at new NodeError (node:internal/errors:405:5)
at packageResolve (node:internal/modules/esm/resolve:863:9)
at moduleResolve (node:internal/modules/esm/resolve:912:20)
at defaultResolve (node:internal/modules/esm/resolve:1105:11)
at nextResolve (node:internal/modules/esm/loader:166:28)
at ESMLoader.resolve (node:internal/modules/esm/loader:840:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:429:18)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:77:40)
at link (node:internal/modules/esm/module_job:76:36)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
The text was updated successfully, but these errors were encountered:
phamhongphuc
changed the title
Cannot use any prettier plugins with yarn 4 + PnP
Cannot use any prettier plugins with yarn 4 + PnPApr 25, 2024
Environments
prettier-plugin-tailwindcss
or any others pluginsDescription
I'm trying to setup a project with
yarn 4 + pnp
+prettier
+prettier-plugin-tailwindcss
(or any others plugins) but I got some problems.In the configuration file, if plugins are declared as string:
The command
yarn prettier .
will return the following error:This is a known bug and has been reported previously in prettier repository (prettier#13276, prettier#15388).
This bug can be fixed with a workaround via
require.resolve()
orimport()
.However, despite the command
yarn prettier .
can be run, prettier extension in VSCode still can't work.Github Repository to Reproduce Issue
Issue reproduction repo: prettier-yarn-issue.
I have already run the command
yarn dlx @yarnpkg/sdks vscode
and committed the changes to the repo.yarn prettier .
prettier-vscode
yarn-4-pnp/cjs/string
yarn-4-pnp/mjs/string
yarn-4-pnp/cjs/require
require.resolve()
yarn-4-pnp/mjs/import
import()
Steps To Reproduce
main
branch doesn't have the prettier config).yarn install
.Developer: Restart Extension Host
if it's already opened).src/index.ts
.Format document with...
>Prettier - Code formatter
.Expected result
If command
yarn prettier .
can run via the above workaround (require.resolve or import),prettier-vscode
must also run.Actual result
Command
yarn prettier .
can run via the above workaround (require.resolve or import) butprettier-vscode
can't run.Prettier Log Output
Log - Error resolve node module
Log - Cannot find package 'prettier' imported from
The text was updated successfully, but these errors were encountered: