Skip to content

fix: fix undefined error in getTailwindConfig #18665

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

Open
wants to merge 1 commit into
base: 3.4
Choose a base branch
from

Conversation

gaultier
Copy link

@gaultier gaultier commented Aug 4, 2025

This fixes this bug:

  ✘ [ERROR] Cannot convert undefined or null to object [plugin postcss]
      
          ../../node_modules/tailwindcss/lib/lib/setupTrackingContext.js:69:33:
            69 │             delete require.cache[file];
               ╵                                  ^
      
          at getTailwindConfig (/Users/philippe.gaultier/company-code/cloud/elements/node_modules/tailwindcss/lib/lib/setupTrackingContext.js:69:34)
          at /Users/philippe.gaultier/company-code/cloud/elements/node_modules/tailwindcss/lib/lib/setupTrackingContext.js:100:92
          at /Users/philippe.gaultier/company-code/cloud/elements/node_modules/tailwindcss/lib/processTailwindFeatures.js:46:11
          at plugins (/Users/philippe.gaultier/company-code/cloud/elements/node_modules/tailwindcss/lib/plugin.js:38:69)
          at LazyResult.runOnRoot (/Users/philippe.gaultier/company-code/cloud/elements/packages/elements-react/node_modules/postcss/lib/lazy-result.js:329:16)
          at LazyResult.runAsync (/Users/philippe.gaultier/company-code/cloud/elements/packages/elements-react/node_modules/postcss/lib/lazy-result.js:258:26)
          at LazyResult.async (/Users/philippe.gaultier/company-code/cloud/elements/packages/elements-react/node_modules/postcss/lib/lazy-result.js:160:30)
          at LazyResult.then (/Users/philippe.gaultier/company-code/cloud/elements/packages/elements-react/node_modules/postcss/lib/lazy-result.js:404:17)

Not sure why we end up in this situation. It typically triggers when everything has been cleaned (rm -rf node_modules && npm ci && npm run build) in my project.

EDIT: On our side we have found out that this issue popped up with node 22.18 and was not present in 22.17.

@gaultier
Copy link
Author

Sharing here my colleague's @pcaillaudm theory on the root cause:

What I suspect being the root cause of the issue is that 22.18 is now able to execute TypeScript files without additional configuration. https://nodejs.org/en/blog/release/v22.18.0
It was not the case in 22.17 so when tailwind would require('./tailwind.config.ts'), it would insert the module into require.cache.
In 22.18, the module is now certainly executed through the new ESM type-stripping loader directly and never added to require.cache
So tailwind’s cache-busting loop tries to delete an entry that isn’t there.

And indeed, the bug does not trigger when running nodejs 22.18 with the option --no-experimental-strip-types.

@thecrypticace thecrypticace self-assigned this Aug 12, 2025
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

Successfully merging this pull request may close these issues.

2 participants