TailwindCSS v4

when I use the second command npx tailwindcss init -p, it gives me:

NPM error could not determine executable to run

TailwindCSS has just released its new v4 version, so all the older v3 documentation has become somewhat outdated.

Changed npx tailwindcss to npx @tailwindcss/cli

The command to run is now no longer npx tailwindcss but npx @tailwindcss/cli.

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.

1
2
npm install tailwindcss @tailwindcss/cli

Deprecated init process

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.

Using the upgrade tool

If you’d like to try upgrading a project from v3 to v4, you can use our upgrade tool to do the vast majority of the heavy lifting for you:

1
2
npx @tailwindcss/upgrade@next

TailwindCSS v3

For a installation, you’ll already be installing v4. However, if you want to install v3, use the old documentation with the following command:

1
2
npm install tailwindcss@3