If you’re trying to set up Tailwind CSS and run into this confusing error:
npx tailwindcss init -p
npm ERR! could not determine executable to run
Don’t panic — this error happens because Tailwind CSS v4 changed its setup process, especially when working with tools like Vite.
In this post, I’ll show you what went wrong and how to set up Tailwind CSS v4 correctly.
✅ Target audience: Developers using Tailwind with Vite
The Error
When I tried to initialize Tailwind CSS the usual way:
npx tailwindcss init -p
It threw this error:
npm ERR! could not determine executable to run
This had worked in previous versions of Tailwind, so I was confused.
Why This Happens in Tailwind CSS v4
Tailwind v4 introduced a simplified setup that no longer uses the CLI initializer (init -p) in January 2025. Instead, Tailwind is installed and configured directly through PostCSS and Vite plugins — making integration easier and reducing boilerplate. Here's the Tailwindcss v4 documentation
How to Fix It (Tailwind v4 Setup with Vite)
Here’s the new and correct way to set up Tailwind CSS v4 with Vite
i). Install Tailwind and PostCSS Plugin
Run this command:
npm install tailwindcss @tailwindcss/vite
ii). Configure Your CSS
At the top of your src/index.css, import Tailwind:
@import "tailwindcss";
iii). Set Up Vite with Tailwind Plugin
In your vite.config.js or vite.config.ts:
import tailwindcss from "@tailwindcss/vite";
export default {
plugins: [
tailwindcss(),
],
};
your vite.config.js/vite.config.ts should look like this:
What Happens Now
After this, just start your dev server:
npm run dev
Tailwind should be working without any errors. No more npx tailwindcss init -p
needed anymore!
Final Thoughts
The Tailwind team is constantly improving the developer experience. The new v4 setup might seem unfamiliar at first, but it’s much cleaner and integrates better with tools like Vite.
If you're still following old tutorials or StackOverflow answers, make sure they're updated for Tailwind v4.
📬 Let's Connect
If you found this helpful or want to discuss anything dev-related, feel free to reach out:
Top comments (0)