idahogurl / vs-code-prettier-eslint

A Visual Studio Code Extension to format JavaScript and TypeScript code using the prettier-eslint package.
MIT License
184 stars 46 forks source link

Not compatible with prettier-plugin-tailwindcss #183

Closed dvakatsiienko closed 9 months ago

dvakatsiienko commented 10 months ago

Describe the bug Extension errors out with Error: Cannot find module 'prettier-plugin-tailwindcss' when prettier-plugin-tailwindcss is added as a plugin to .prettierrc.js.

To Reproduce Steps to reproduce the behavior:

  1. npm i prettier-plugin-tailwindcss
  2. Add prettier-plugin-tailwindcss as a plugin to .prettierrc.js
  3. Restart VSCode
  4. Open «Output» section of VSCode and select Prettier ESLint
  5. Format a document
  6. Observer error Error: Cannot find module 'prettier-plugin-tailwindcss'

Expected behavior Extension should support simple tailwind plugin for class sorting.

Example Prettier Config

/** @type {import("prettier").Config} */
module.exports = {
    tailwindFunctions: ['clsx'],
    plugins: ['prettier-plugin-tailwindcss'],
};

Screenshots Screenshot 2023-08-25 at 16 58 52@2x

Screenshot 2023-08-25 at 16 59 14@2x

Versions (please complete the following information):

System Specifications (please complete the following information):

idahogurl commented 10 months ago

@dvakatsiienko If you look closely at your error message, you'll see the error is coming from the esbenp.prettier extension not mine.

dvakatsiienko commented 10 months ago

@idahogurl Yes, you're right. I've accidentally had two prettiers installed. After deleting an official one, the same error persists, pointing to this extension.

Error: Cannot find module 'prettier-plugin-tailwindcss'
Require stack:
- /Users/furthur/Projects/_anadea/rocky-ui-gitlab/node_modules/.pnpm/prettier@2.8.8/node_modules/prettier/index.js
- /Users/furthur/.vscode/extensions/rvest.vs-code-prettier-eslint-5.1.0/dist/extension.js
- /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js
- /Applications/Visual Studio Code.app/Contents/Resources/app/out/bootstrap-amd.js
- /Applications/Visual Studio Code.app/Contents/Resources/app/out/bootstrap-fork.js
-  
Error: Cannot find module 'prettier-plugin-tailwindcss'
Require stack:
- /Users/furthur/Projects/_anadea/rocky-ui-gitlab/node_modules/.pnpm/prettier@2.8.8/node_modules/prettier/index.js
- /Users/furthur/.vscode/extensions/rvest.vs-code-prettier-eslint-5.1.0/dist/extension.js
- /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js
- /Applications/Visual Studio Code.app/Contents/Resources/app/out/bootstrap-amd.js
- /Applications/Visual Studio Code.app/Contents/Resources/app/out/bootstrap-fork.js
- 
    at Module._resolveFilename (node:internal/modules/cjs/loader:1010:15)
    at Function.s._resolveFilename (node:electron/js2c/utility_init:2:2740)
    at g.resolve (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js:4:709)
    at /Users/furthur/Projects/_anadea/rocky-ui-gitlab/node_modules/.pnpm/prettier@2.8.8/node_modules/prettier/index.js:38119:25
    at Array.map (<anonymous>)
    at Object.load (/Users/furthur/Projects/_anadea/rocky-ui-gitlab/node_modules/.pnpm/prettier@2.8.8/node_modules/prettier/index.js:38114:65)
    at Object.load [as loadPlugins] (/Users/furthur/Projects/_anadea/rocky-ui-gitlab/node_modules/.pnpm/prettier@2.8.8/node_modules/prettier/index.js:16147:23)
    at /Users/furthur/Projects/_anadea/rocky-ui-gitlab/node_modules/.pnpm/prettier@2.8.8/node_modules/prettier/index.js:38181:24
    at Object.format (/Users/furthur/Projects/_anadea/rocky-ui-gitlab/node_modules/.pnpm/prettier@2.8.8/node_modules/prettier/index.js:38197:12)
    at /Users/furthur/.vscode/extensions/rvest.vs-code-prettier-eslint-5.1.0/dist/extension.js:189:131
    at zme (/Users/furthur/.vscode/extensions/rvest.vs-code-prettier-eslint-5.1.0/dist/extension.js:185:1460)
Screenshot 2023-08-29 at 17 17 58@2x
idahogurl commented 10 months ago

@dvakatsiienko I wonder if the issue is that you are using PNPM as your package manager. Can you use the pretter CLI and see if you get the same error?

dvakatsiienko commented 10 months ago

@idahogurl I've tried to wipe out pnpm and use yarn with same configuration, it produces same error.

github-actions[bot] commented 9 months ago

This issue is stale because it has been open for 14 days with no activity.

github-actions[bot] commented 9 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.

mbrgm commented 8 months ago

I have the same error. Any recommendations?

jedimonkey commented 4 months ago

I've had some success with this wrapping the plugins with require.resolve See https://github.com/prettier/prettier/issues/13276