Skip to content

Tailwind Vite plugin in Astro causes type errors in Astro Vite config in Node >=22.12 #19210

@JamesJosephFinn

Description

@JamesJosephFinn

Hello team Tailwind!

This is my first Tailwind Astro project, so please pardon my lack of familiarity with your process. If anything in this report is out of order, let me know, and I'll fix it straight away.

What version of Tailwind CSS are you using?

v4.1.16

What build tool (or framework if it abstracts the build tool) are you using?

Vite, via Astro

What version of Node.js are you using?

Greater than or equal to 22.12

What browser are you using?

N/A

What operating system are you using?

N/A ... node issue, described below

Reproduction URL

https://idx.google.com/tailwind-vite-09606533

N.B. – The above IDX / Firebase Studio environment has been shared with @RobinMalfait 's gmail.

Describe your issue

Firstly, I'm not sure how to get IDX to use a specific version of node, as they utilize Nix, and that's not my jam. So I installed nvm into the environment, and added .nvmrc, which is presently set to node v22.12.0.

In the repro IDX environment (above), run npm run typecheck (which is Astro's wrapper around tsc). The errors in vitest.config.ts and astro.config.ts are what's pertinent to this issue.

The errors will resolve if you run either of the following corrective workflows:

npm rm tailwindcss @tailwindcss/vite
rm -rf node_modules/
rm package-lock.json
npm i

Then, comment out astro.config.ts tailwind stuff before running type checking, like so:

// import tailwindcss from '@tailwindcss/vite';

export default defineConfig({
  vite: {
    // plugins: [tailwindcss()],
  },
});

Then run npm run typecheck. You'll see the vitest.config.ts type error inside Astro's Vite config is no longer there, after uninstalling tailwindcss and @tailwindcss/vite.

Something's up with Tailwind and Vite inside Astro!


Alternatively, instead of the above corrective workflow, you can downgrade node, like so:

nvm use 22.10.0 --save
rm -rf node_modules/
rm package-lock.json
npm i
npm run typecheck

Unfortunately, I need node greater than or equal to v22.12, so this is not an option!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions