Skip to content
nkNilay Kabariya

Entry No.009·Fixes··1 min read

Fix: “trying to use tailwindcss directly as a PostCSS plugin”

Tailwind CSS v4 moved its PostCSS plugin to a separate package. The two-line change to postcss.config.js, reproduced and verified.

by Nilay#tailwind#postcss#cssFIXED

The error, verbatim

Jump to the fix ↓
Error: It looks like you're trying to use `tailwindcss` directly as a PostCSS
plugin. The PostCSS plugin has moved to a separate package, so to continue
using Tailwind CSS with PostCSS you'll need to install `@tailwindcss/postcss`
and update your PostCSS configuration.

Tested on

tailwindcss
4.3.3
@tailwindcss/postcss
4.3.3
postcss / cli
8.5.28 / postcss-cli 12.0.0
Node / OS
24.14.0 / Windows 11 Pro
Contents
  1. The fix01
  2. Why it happens02
  3. Can I keep autoprefixer?03
  4. What didn’t work04

The fix

Install the new plugin package:

npm install -D @tailwindcss/postcss

Then change the plugin name in postcss.config.js (or .mjs / .cjs) from tailwindcss to @tailwindcss/postcss:

module.exports = {
  plugins: {
    "@tailwindcss/postcss": {},
  },
};

Your CSS entry file should import Tailwind the v4 way:

@import "tailwindcss";

Why it happens

Up to v3, the tailwindcss package was the PostCSS plugin, so every guide told you to write tailwindcss: {} in postcss.config.js. In v4 the plugin lives in its own package, @tailwindcss/postcss. The main package now throws this error on purpose when PostCSS tries to load it the old way.

It usually shows up when a project upgrades to v4, or when you follow a v3 tutorial but npm install gives you v4.

Can I keep autoprefixer?

Yes. With autoprefixer: {} left in the config, the build still succeeded. But Tailwind v4 adds vendor prefixes itself, so you can remove autoprefixer from the config and uninstall it.

What didn’t work

— N.K., end of entry No.009

Useful? Pass it on:Post on X

Related entries

  1. No.008

    Fix: “Cannot apply unknown utility class” in Tailwind CSS v4

    Two causes trigger this Tailwind v4 error: an unmapped theme variable (border-border) or a CSS file missing @reference. Both reproduced and fixed.

    > Error: Cannot apply unknown utility class `border-border`

    FIXED1 min
  2. No.007

    Fix: npx tailwindcss init “could not determine executable to run”

    Tailwind CSS v4 removed the init command, so npx has nothing to run. Two fixes, both reproduced: set up v4 without a config file, or pin v3.

    > $ npx tailwindcss init

    FIXED2 min
  3. No.010

    Fix: Vite “Failed to resolve import” for @ alias imports

    Vite can't find an @/ import until the alias is in vite.config. Why tsconfig paths alone don't help, and the new Vite 8 Rolldown wording. Reproduced.

    > [vite] Internal server error: Failed to resolve import "@/utils/hello"

    FIXED1 min

Post card · Newsletter

Get the next fix in your inbox.

One short email when a new entry is published. No spam, never shared, and you can leave any time.

— Nilay

or follow by RSS

By subscribing you agree to the privacy note. One click to leave.

tip: paste the exact error text