language-tools icon indicating copy to clipboard operation
language-tools copied to clipboard

🐛 BUG: Couldn't load `prettier` or `prettier-plugin-astro` when using Yarn PnP

Open imballinst opened this issue 1 year ago • 2 comments

Describe the Bug

I am using Yarn berry in my project, which I believe is already supported: https://github.com/withastro/language-tools/issues/370 (and I could install the Astro language server nicely).

However, I'm getting this message/error when I'm opening an .astro file:

Couldn't load prettier or prettier-plugin-astro. Formatting will not work. Please make sure those two packages are installed into your project.

I tried to replicate it in a repository (using Codespaces: https://github.com/imballinst/astro-yarn-berry-pnp), and it seems I am able to replicate the behavior. Do you might have an idea on what I should do, or could you point me out to a documentation that I could use? Thanks! 🙇‍♂️

Steps to Reproduce

With the sample repository:

  1. git clone [email protected]:imballinst/astro-yarn-berry-pnp.git
  2. Open the folder in VS Code
  3. Go to src/layouts/Layout.astro
  4. See notification popping up on bottom right, and we can't quite prettify Astro files

image

This is despite that prettier is already installed as devDependencies and I have the Prettier SDK already:

"devDependencies": {
  "@astrojs/language-server": "2.3.3",
  "prettier": "3.0.3"
}

In the extension output, I got this:

["ERROR" - 10:05:32 AM] Failed to resolve a parser, skipping file. If you registered a custom file extension, be sure to configure the parser.

imballinst avatar Sep 26 '23 10:09 imballinst