Vite reports that tailwindcss cannot be used directly as a PostCSS plugin
Internal server error: [postcss] It looks like you're trying to use `tailwindcss` directly as a PostCSS plugin.Short answer
In Tailwind CSS v4 the PostCSS plugin moved out of the tailwindcss package. A v3-style postcss.config that lists tailwindcss now fails. In a Vite project, delete that config entry, install @tailwindcss/vite, add it to vite.config, and import Tailwind with a plain CSS @import line.
Fix it fast
1Find out which cause you have
Check which Tailwind version is installed, then look at your PostCSS config.
npm ls tailwindcss cat postcss.config.* 2>/dev/null2Match what you see, then jump to its fix
What does the error look like?
Internal server error: [postcss] It looks like you're trying to use `tailwindcss` directly as a PostCSS plugin.
Cause 1 of 3
A v3 postcss.config still names tailwindcss
1Check
The upgrade guide says the v3 package was the PostCSS plugin, and in v4 it lives in a dedicated package.
grep -n "tailwindcss" postcss.config.*2Fix
For Vite, the recommended route is the Vite plugin. Install it, register it, and remove the Tailwind entry from the PostCSS config (delete the file if nothing else is in it).
npm install tailwindcss @tailwindcss/vite
// vite.config.ts
import { defineConfig } from 'vite'
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
plugins: [tailwindcss()],
})3Verify
Restart the dev server. The error should be gone.
npm run devConfirmed by tailwindcss.com
Cause 2 of 3
You want to keep PostCSS
1Check
If you choose PostCSS, the plugin name changes to @tailwindcss/postcss. v4 also handles imports and vendor prefixes itself, so postcss-import and autoprefixer can be removed.
npm ls @tailwindcss/postcss2Fix
Install the new package and list it in place of tailwindcss.
npm install @tailwindcss/postcss
// postcss.config.mjs
export default {
plugins: {
"@tailwindcss/postcss": {},
},
};3Verify
Restart the dev server.
npm run devConfirmed by tailwindcss.com
Cause 3 of 3
The stylesheet still uses the v3 directives
1Check
v3 used three @tailwind lines. v4 uses one CSS import.
grep -rn "@tailwind\|@import \"tailwindcss\"" src/2Fix
Replace the old lines with the import.
/* src/index.css */
@import "tailwindcss";3Verify
Add a utility class such as text-3xl to an element and reload.
npm run devConfirmed by tailwindcss.com
How do I stop it coming back?
- After the upgrade, keep only one Tailwind entry point: the Vite plugin or the PostCSS plugin, not both.
- Read the upgrade guide before you move a project from Tailwind v3 to v4.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
npx stops with 'could not determine executable to run'
npm ERR! could not determine executable to run
npx picks the command from the package's bin field.
3 causes, each with a fixBack end
ng serve says it cannot determine the project or target
Cannot determine project for command.
The Angular CLI looked through angular.json for a project that defines the target you asked for (serve, build, test) and found none, or found several and could not pick one.
3 causes, each with a fixBack end
ng fails with Cannot find module @angular/cli/bin/ng
Cannot find module '@angular/cli/bin/ng'
The ng command is the entry point to the Angular CLI package.
2 causes, each with a fixBack end
Angular app shows 'Cannot GET /' when served by a Node.js server
Cannot GET /dashboard
Cannot GET / is Express saying no route or file matches the request.
3 causes, each with a fixBack end
ng serve cannot find the dev-server builder package
Could not find the implementation for builder @angular/build:dev-server
The builder named in angular.json (for example @angular-devkit/build-angular:dev-server) is looked up as an npm package starting from the workspace root.
3 causes, each with a fixBack end
Angular build says it cannot resolve '@angular/localize/init'
Can't resolve '@angular/localize/init' in '/usr/src/app/src'
The build imports @angular/localize, and that package is not in node_modules.
2 causes, each with a fix