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

Can't load plugins when using Yarn v2 #80

Open
KarimTayel opened this issue Apr 8, 2021 · 0 comments
Open

Can't load plugins when using Yarn v2 #80

KarimTayel opened this issue Apr 8, 2021 · 0 comments

Comments

@KarimTayel
Copy link

Hi,

I'm trying to use this plugin prettier-plugin-twig-enhancements, but every time I try to run Prettier it gives me an error:

Could not load plugin path node_modules/prettier-plugin-twig-enhancements

I tried to use yarn unplug prettier-plugin-twig-enhancements and point to the plugin folder inside the .yarn/unplugged folder but it didn't work either.

.prettierrc.js (Not Working)

module.exports = {
  ...
  plugins: ['prettier-plugin-twig-melody']
  twigMelodyPlugins: ['node_modules/prettier-plugin-twig-enhancements']
}

.prettierrc.js (Not Working)

module.exports = {
  ...
  plugins: ['prettier-plugin-twig-melody']
  twigMelodyPlugins: ['.yarn/unplugged/prettier-plugin-twig-enhancements-virtual-c783cdfae2/node_modules/prettier-plugin-twig-enhancements']
}

After many tries, the only working solution was to reference the plugin folder with an absolute path using Node.js Path API.

.prettierrc.js (Working)

const path = require('path');

module.exports = {
  ...
  plugins: ['prettier-plugin-twig-melody']
  twigMelodyPlugins: [
    `${path.resolve(
      '.yarn/unplugged/prettier-plugin-twig-enhancements-virtual-c783cdfae2/node_modules/prettier-plugin-twig-enhancements',
    )}`,
  ]
}
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

1 participant