TailwindCSS v3
The error is here:
npm install -D tailwindcss postcss autoprefixer
Since January 2025, the npm install tailwindcss command installs the new v4 version instead of the old v3. If you want to use TailwindCSS v3, follow:
npm install -D tailwindcss@3 postcss autoprefixer
Breaking changes from v4
The use of tailwind.config.js has been removed, and instead, you can use a simple CSS-first configuration. However, it's possible to use the legacy JavaScript-based configuration via the @config directive.
Additionally, the @tailwind directive has been deprecated since v4. Use
@import "tailwindcss";
instead.
In v4, the installation process has changed. It's now simpler. The init command has become obsolete and is no longer usable from v4 onwards because it's not needed anymore.
Other related breaking changes in v4:
TailwindCSS v4 with PostCSS
If you're interested in the new v4 version, review the many breaking changes and the new installation steps:
npm install tailwindcss @tailwindcss/postcss postcss
postcss.config.mjs
export default {
plugins: {
"@tailwindcss/postcss": {},
}
}
app.css
@import "tailwindcss";
TailwindCSS v4 with CLI (without PostCSS)
Starting from v4, Vite, PostCSS, and CLI plugins have been split into 3 separate packages. It’s up to you which one you need. If you only need a clean TailwindCSS setup without Vite or PostCSS, you can use the CLI like this:
npm install tailwindcss @tailwindcss/cli
app.css
@import "tailwindcss";
The npx tailwindcss command is completely deprecated starting from v4, and instead, the npx @tailwindcss/cli command is used, like this:
npx @tailwindcss/cli -i ./src/input.css -o ./src/output.css --watch
PostCSS plugin and CLI are separate packages — the main tailwindcss package doesn't include these anymore since not everyone needs them, instead they should be installed separately using @tailwindcss/postcss and @tailwindcss/cli.
Source: Open-sourcing our progress on Tailwind CSS v4.0 - Whats changed
This is basically only necessary if you're not using it with a framework and want to run it from the command line. For this, a standalone @tailwindcss/cli package will help from v4 onwards.
But remember: the init process (which you mentioned in the question) has been removed starting from v4. There's no need for it, as tailwind.config.js is also no longer required in v4. Read more about the CSS-first configuration or v3 compatibility: