Unable to setup tailwind in react + vite #18242
Unanswered
curiouscatcode
asked this question in
Help
Replies: 1 comment
-
The If you are trying to use v3, ensure the version qualifier is used: $ npm install -D tailwindcss@3 postcss autoprefixer
$ npx tailwindcss init -p |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
🐛 Bug: Unable to run
npx tailwindcss init -p
in React + Vite setup❓ Problem Summary
I am trying to set up Tailwind CSS in a React + Vite project, but running
npx tailwindcss init -p
gives me the following error:Despite Tailwind CSS being present in
node_modules
, there is notailwindcss
binary insidenode_modules/.bin
— hence,npx
cannot run it.🔍 Reproduction Steps
Created a new folder:
mkdir tailwindCSS_tutorial && cd tailwindCSS_tutorial
Initialized a Vite React project:
npm create vite@latest tailwind_freecodecamp -- --template react
Installed dependencies:
Tried to initialize Tailwind config:
npx tailwindcss init -p
💥 Error occurred:
📦 Current Environment
C:\Users\hp\OneDrive\Desktop\tailwindCSS_tutorial\tailwind_freecodecamp
🔎 Observations
Running
npm ls tailwindcss
confirms Tailwind is installed:But there is no executable file generated in
node_modules/.bin/
for Tailwind CSS.Hence, this fails:
Installing Tailwind v3.x (e.g.,
tailwindcss@3.4.3
) does create.bin/tailwindcss
, and the init command works fine.However, in that case, VS Code gives 3 problems in
index.css
like:📌 What I Tried
npm cache clean --force
node_modules
,package-lock.json
tailwind.config.js
,postcss.config.js
, and project structure — everything was correct❗ Expected Behavior
npm install -D tailwindcss
, runningnpx tailwindcss init -p
should work by default.node_modules/.bin/tailwindcss
should exist and be runnable.📩 Request
Please look into why:
npx tailwindcss
fails to detect the executable in Tailwind v4+.bin/tailwindcss
is missing in V4, but not in V3@tailwind
as unknown rule even when IntelliSense is installedThe problem is when i install the way it is told in the docs, it gets install but tailwind.config.js and postcss.config.js aren't made which according to the tutor i am following said is needed to customize, dark mode and etc
Beta Was this translation helpful? Give feedback.
All reactions