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 -pin React + Vite setup❓ Problem Summary
I am trying to set up Tailwind CSS in a React + Vite project, but running
npx tailwindcss init -pgives me the following error:Despite Tailwind CSS being present in
node_modules, there is notailwindcssbinary insidenode_modules/.bin— hence,npxcannot run it.🔍 Reproduction Steps
Created a new folder:
mkdir tailwindCSS_tutorial && cd tailwindCSS_tutorialInitialized a Vite React project:
npm create vite@latest tailwind_freecodecamp -- --template reactInstalled 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 tailwindcssconfirms 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.csslike:{ "message": "Unknown at rule @tailwind", "source": "css", "code": "unknownAtRules", "severity": 4 }📌 What I Tried
npm cache clean --forcenode_modules,package-lock.jsontailwind.config.js,postcss.config.js, and project structure — everything was correct❗ Expected Behavior
npm install -D tailwindcss, runningnpx tailwindcss init -pshould work by default.node_modules/.bin/tailwindcssshould exist and be runnable.📩 Request
Please look into why:
npx tailwindcssfails to detect the executable in Tailwind v4+.bin/tailwindcssis missing in V4, but not in V3@tailwindas 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