tailwindlabs / prettier-plugin-tailwindcss

A Prettier plugin for Tailwind CSS that automatically sorts classes based on our recommended class order.
MIT License
5.61k stars 133 forks source link

Error Require of ES Module not supported in v0.5.0 #196

Closed codeflorist closed 1 year ago

codeflorist commented 1 year ago

What version of prettier-plugin-tailwindcss are you using?

v0.5.0

What version of Tailwind CSS are you using?

v3.3.3

What version of Node.js are you using?

v18.16.1

What package manager are you using?

yarn

What operating system are you using?

Windows

Describe your issue

v0.5.0 throws the following error:

[error] require() of ES Module ...path\node_modules\prettier-plugin-tailwindcss\dist\index.mjs not supported.
[error] Instead change the require of ..path\node_modules\prettier-plugin-tailwindcss\dist\index.mjs to a dynamic import() which is available in all CommonJS modules.

v0.4.1 is working without problems.

thecrypticace commented 1 year ago

What version of Prettier are you using?

Mini-ghost commented 1 year ago

I have the same problem, my prettier version is v2.8.8

devDependencies:
eslint-plugin-prettier-vue 4.2.0
└── prettier 2.8.8
prettier-plugin-tailwindcss 0.5.0
└── prettier 2.8.8 peer
thecrypticace commented 1 year ago

v0.5.0 requires a minimum of Prettier v3.0 now. If you still need Prettier v2.8 stick to v0.4.

codeflorist commented 1 year ago

Ah, i see. That must bei it. Thanks!

matthewwilson commented 1 year ago

I'm seeing the same error on Prettier 3.0.1

EDIT

Got this working, had to change:

plugins: [require("prettier-plugin-tailwindcss")],

to

plugins: ["prettier-plugin-tailwindcss"],

taoliujun commented 1 year ago

@matthewwilson still have the same error, even i update prettier@^3, and i set plugins: ["prettier-plugin-tailwindcss"],.

Ignoring my question, I see that the prettier version in the log is 2.8, so I update the vscode prettier plugin and it works fine.