question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

prettier-vscode not working for files managed by plugin when installed through pnpm

See original GitHub issue

Summary

prettier-vscode ignore plugins when used in a vscode workspace in a mono repo installed with pnpm

Github Repository to Reproduce Issue

https://github.com/wighawag/issue-prettier-pnpm

Steps To Reproduce:

  1. git clone https://github.com/wighawag/issue-prettier-pnpm
  2. pnpm install
  3. open vs code
  4. edit a .svelte file and save

Expected result

Expect prettier to prettify every files, including the one handled by prettier plugins (like .svelte file)

Actual result

The .svelte file are completely ignored by vscode, even though the plugin for svelte is installed.

Note that it works fine when the mono repo is installed with yarn, see yarn branch here : https://github.com/wighawag/issue-prettier-pnpm/tree/yarn

VS Code Version: 1.52.0

Prettier Extension Version: 5.8.0

OS and version: Windows 10

Prettier Log Output

When saving a .svelte file no log get outputed. also the prettier icon do not show up for these files

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:9
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
ghostcommented, Mar 31, 2021

Just tested switching my repository from Yarn Classic/v1 to pnpm (after having unsuccessfully tried using Yarn v2/PnP cause it breaks everything) and was surprised by the speed bump, less disk space usage and that everything continued to work fine. This appears to be the only caveat I have found with using pnpm so far; I’m not sure if this is pnpm’s fault or if pnpm simply hasn’t been accounted for by the prettier devs, but I’d really like to see prettier plugins work again in my IDE 😄 Edit: The plugin in question not working for me is prettier-plugin-package which sorts the package.json file and used to work before. Seeing that you’re having issues with a different plugin, this appears to be a pnpm<>prettier-vscode issue, not a plugin-specific one. Running prettier over the command line (with pnpx prettier --fix --plugin-search-dir=. package.json) works as expected.

1reaction
willsotocommented, Jul 10, 2021

As a workaround for this, you can create a .prettierrc.js in the monorepo and use require.resolve to generate the complete path to the plugin. Example:

module.exports = {
  plugins: [require.resolve("prettier-plugin-svelte")]
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

In VS Code, I'm getting this error, 'Failed to load module ...
This is a solution that worked for me. 1. Install Prettier Globally via npm if you have never installed it globally npm i...
Read more >
Plugins - Prettier
Plugins are ways of adding new languages or formatting rules to Prettier. Prettier's own implementations of all languages are expressed using the plugin...
Read more >
Prettier plugin does not support local installation with pnpm
The IDE Prettier plugin should work as expected with .java files when installing the plugin for it. What happens instead? Nothing happens on...
Read more >
prettier-plugin-astro - npm Package Health Analysis - Snyk
When submitting issues about formatting in VS Code, first make sure you're actually using Prettier to format your files and not the Astro...
Read more >
Your Open Source Project Needs a devcontainer - Here's Why
This is just a plain old Dockerfile , you can run it without VS Code ... so I'll make sure that's installed, along...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found