11

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'

5

8 Answers 8

30

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.

15

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
0
7

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:

TailwindCSS v3

If you still want to use v3, install it with a specific version:

npm install tailwindcss@3

TailwindCSS v4

If you're looking for breaking changes in v4 (why not working npx tailwindcss init), here's a quick summary:

  • CSS-first configuration replaces tailwind.config.js.
  • The init process has been removed since it's no longer needed.
  • The CLI and PostCSS packages have been separated, so to use 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:

4
  1. Check if your directory is initialized as a node project, i.e. it contains package.json file. If not then do this:
$/> npm init -y
  1. Install tailwindcss as a dev dependency (optional as a dev dependency)
$/> npm i -D tailwindcss
3
2

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

2
1

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.

0

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

1
0

you should to install v3
command:
npm install -D tailwindcss@3 postcss autoprefixer
then:
npx tailwindcss init -p

3

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.