-
-
Notifications
You must be signed in to change notification settings - Fork 459
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
Cannot use any prettier plugins with yarn 4 + PnP
#3380
Comments
yarn 4 + PnP
yarn 4 + PnP
I'm experiencing the same problem. 😭 |
After bump
/** @type {import('prettier').Config} */
const prettierConfig = {
plugins: [require.resolve("prettier-plugin-tailwindcss")],
};
module.exports = prettierConfig; But the I think it's because
{
"name": "prettier",
"version": "3.3.3",
"description": "Prettier is an opinionated code formatter",
"bin": "./bin/prettier.cjs",
// ...
} |
Running into this same issue. The suggestion by @phamhongphuc does work for now:
Specifically:
|
Still having this problem with yarn pnp using
Tried debugging the extension in vscode development host but I can't seem to find the place that throws the error. It happens during tried updating
Anyone got any other ideas where I could look |
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: