I'm following the documentation, however when use:
npx tailwindcss init
Not working:
Error: Cannot find module 'C:\path\to\project\tailwindcss\lib\cli.js'
I'm following the documentation, however when use:
npx tailwindcss init
Not working:
Error: Cannot find module 'C:\path\to\project\tailwindcss\lib\cli.js'
Step : 1
Correct you directory path like this C:\Users\user\Documents\Web Dev\Tailwindcss_AlpineJs\pratice tailwind
then try this command npx tailwindcss init
Step : 2
Not working above step : 1 then try this command : npx tailwindcss-cli@latest init -p
.
The latest version Tailwindcss@4 does not support -> npx tailwindcss init
Installation Using PostCSS
I installed the Tailwindcss@3 version , the command is running fine . Steps :-
npm init -y
npm install -D tailwindcss@3 @tailwindcss/postcss postcss
npx tailwindcss init -p
I know the question was based on TailwindCSS v3, but newcomers will increasingly use v4, so I'll provide a v4-related answer.
Starting from January 2025, with the release of TailwindCSS v4, running npm install tailwindcss will install the new v4 instead of v3. This is important because v4 comes with several breaking changes.
v4 related similar question:
If you still want to use v3, install it with a specific version:
npm install tailwindcss@3
If you're looking for breaking changes in v4 (why not working npx tailwindcss init
), here's a quick summary:
tailwind.config.js
.init
process has been removed since it's no longer needed.npx tailwindcss
, you now need the @tailwindcss/cli
package, and the new command is: npx @tailwindcss/cli
. But for usage with PostCSS or Vite, no CLI command is needed anymore.See more:
package.json
file. If not then do this:$/> npm init -y
$/> npm i -D tailwindcss
init
process, because JS-based configuration is no longer needed. See: Problem installing TailwindCSS after npx tailwindcss init
command - tailwindcss not recognized - NPM error could not determine executable to run and maybe related for you: What's breaking changes from v4?
Commented
Aug 17 at 14:33
i was facing the same issue installing tailwindcss and postcss with vite but i was able to fix this issue by adding the tailwind.config.ts file manually and filling in the required information then i added the tailwindcli in my project with the command given above
I encountered the same issue with the Nuxt Tailwind CSS module. It occurred because I had been using pnpm as the package manager. Switching to npm resolved the error. Additionally, manually installing the Tailwind CSS package and setting it up should prevent similar errors from occurring.
I had the same problem in my case, the parent folder had &, something like "Html&Css" and even if there was another folder here, the error was resolved after I removed the & from the parent folder.
So, the error was solved after I eliminated the "&"
I hope it helps someone. And it took me a while to find what the problem was
init
process, because JS-based configuration is no longer needed. See: Problem installing TailwindCSS after npx tailwindcss init
command - tailwindcss not recognized - NPM error could not determine executable to run and maybe related for you: What's breaking changes from v4?
Commented
Aug 17 at 14:35
you should to install v3
command:
npm install -D tailwindcss@3 postcss autoprefixer
then:
npx tailwindcss init -p
practice tailwind
directory initialized as node project?