SyntaxError: Identifier 'require' has already been declared
jamesstoneco opened this issue · comments
What version of prettier-plugin-tailwindcss
are you using?
0.5.6
What version of Tailwind CSS are you using?
3.3.3
What version of Node.js are you using?
v18.7.1
What package manager are you using?
yarn
What operating system are you using?
macOS
Reproduction URL
https://github.com/jamesstoneco/bug-report-tailwind-sort-plugin
yarn install
yarn build-css
Describe your issue
I am getting an error when trying to add the prettier-plugin-typescript
to my project. I have tried different configurations, but I get similar results. with the repo above you should be able to produce the following output / error:
should result in the following
/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:4
const require=_module2.createRequire.call(void 0, import.meta.url)
^
SyntaxError: Identifier 'require' has already been declared
at new Script (node:vm:94:7)
at createScript (node:vm:251:10)
at Object.runInThisContext (node:vm:299:10)
at evalModule (/Users/james/kisko-nda/avica/bug-report-tailwind-sort-plugin/node_modules/jiti/dist/jiti.js:1:255425)
at jiti (/Users/james/kisko-nda/avica/bug-report-tailwind-sort-plugin/node_modules/jiti/dist/jiti.js:1:253542)
at /Users/james/kisko-nda/avica/bug-report-tailwind-sort-plugin/tailwind.config.ts:7:66
Node.js v18.17.1
error Command failed with exit code 1.
Same issue. using
"prettier": "^3.0.3",
"prettier-plugin-tailwindcss": "^0.5.6",
Hey, this is because you're including the prettier plugin in the tailwind config file rather than in the Prettier config file. Make sure you create a prettier config, are using Prettier v3, and follow the installation instructions in our readme.
I've opened a PR showing how to fix this in your repro: jamesstoneco/bug-report-tailwind-sort-plugin#1
Thanks, It's working now.