-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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
After updating to v22.12, always got ReferenceError: require is not defined in tailwind config #56140
Comments
If so, then you may want to either remove it, or change your tailwind config to be a |
Considering you are using vite, you may have As to why this starts to happen in v22.12, I am guessing it might be similar to #56127 (comment) ? Some package in your toolchain may have been monkey patching the Node.js CJS loader internals to hide this bug, and we changes the signature of some internal methods (specifically module format is now passed as a third argument of |
Use ESM-`import` to import `daisyui` in `tailwind.config.js`. Fails to compile in node 22.12.0 (but not in 22.11.0). Using CJS-syntax is not allowed, as `package.json` sets `type: module`. This means that all `.js`-files are interpreted as ESM-modules. See nodejs/node#56140 (comment)
Use ESM-`import` to import `daisyui` in `tailwind.config.js`. Fails to compile in node 22.12.0 (but not in 22.11.0). Using CJS-syntax is not allowed, as `package.json` sets `type: module`. This means that all `.js`-files are interpreted as ESM-modules. See nodejs/node#56140 (comment)
Use ESM-`import` to import `daisyui` in `tailwind.config.js`. Fails to compile in node 22.12.0 (but not in 22.11.0). Using CJS-syntax is not allowed, as `package.json` sets `type: module`. This means that all `.js`-files are interpreted as ESM-modules. See nodejs/node#56140 (comment)
Version
v22.12.0
Platform
Subsystem
No response
What steps will reproduce the bug?
npm run build on vite project that has already setup tailwindcss and shadcnui
How often does it reproduce? Is there a required condition?
always
What is the expected behavior? Why is that the expected behavior?
build succeded
What do you see instead?
$ tsc -b && vite build
♻️ Generating routes...
✅ Processed routes in 285ms
vite v6.0.0 building for production...
transforming (1) src/main.tsxfile:///Users/......./tailwind.config.js:74
plugins: [require("tailwindcss-animate")],
^
ReferenceError: require is not defined
at file:///Users/......./tailwind.config.js:74:11
at ModuleJobSync.runSync (node:internal/modules/esm/module_job:395:35)
at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:329:47)
at loadESMFromCJS (node:internal/modules/cjs/loader:1414:24)
at Module._compile (node:internal/modules/cjs/loader:1547:5)
at Object..js (node:internal/modules/cjs/loader:1677:16)
at Module.load (node:internal/modules/cjs/loader:1318:32)
at Function._load (node:internal/modules/cjs/loader:1128:12)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:219:24)
Node.js v22.12.0
Additional information
i found this bug when i deploy it to vercel, but in my local it succeded built. and when i checked the node version of vercel it use v22.12.0, and at the time in my local i use v22.11.0. so when i update to the v22.12.0, it has the same error as vercel's build log. so i think the error is from v22.12.0
The text was updated successfully, but these errors were encountered: