admin管理员组文章数量:1405393
I have been trying to install vite with tailwindcss, but I keep getting this error:
[vite] Internal server error: [postcss] It looks like you're trying to use
tailwindcss
directly as a PostCSS plugin. The PostCSS plugin has moved to a separate package, so to continue using Tailwind CSS with PostCSS you'll need to install@tailwindcss/postcss
and update your PostCSS configuration.
I used chatgpt to include some files that were missing but it's still throwing that error
I have been trying to install vite with tailwindcss, but I keep getting this error:
[vite] Internal server error: [postcss] It looks like you're trying to use
tailwindcss
directly as a PostCSS plugin. The PostCSS plugin has moved to a separate package, so to continue using Tailwind CSS with PostCSS you'll need to install@tailwindcss/postcss
and update your PostCSS configuration.
I used chatgpt to include some files that were missing but it's still throwing that error
Share Improve this question edited Mar 23 at 7:23 marc_s 756k184 gold badges1.4k silver badges1.5k bronze badges asked Mar 22 at 15:04 user30024141user30024141 1 5 |2 Answers
Reset to default 0Just follow the official documentation here.
Also verify these files:
- After installing tailwindcss make sure your vite.config.js looks like this.
import {
defineConfig
} from 'vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
// https://vite.dev/config/
export default defineConfig({
plugins: [react(), tailwindcss()],
})
- Update your index.css located in src/ dir (your-vite-app/src/index.css) Make sure you have written this line at the top:
@import "tailwindcss";
- Then all set, just restart the webapp, (npm run dev)
Although you haven't shared much information, this error message occurs when you follow an old v3 installation guide but install Tailwind CSS with npm install tailwindcss
, which has been installing v4 since January 2025.
- Loading PostCSS Plugin failed: Cannot find module 'tailwindcss' error when I run using vite
v4 introduces many breaking changes and a new installation method.
If you want to install v3, use:
npm install tailwindcss@3
If you want v4, follow:
- Solution #1: TailwindCSS v4 & Vite without PostCSS - StackOverflow
- Solution #2: PostCSS & Vite with TailwindCSS v4 - StackOverflow
Related:
- What changes from TailwindCSS v4? - StackOverflow
本文标签: reactjsI am trying to use vite with tailwind and I keep getting this errorStack Overflow
版权声明:本文标题:reactjs - I am trying to use vite with tailwind and I keep getting this error - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744310594a2600008.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
[postcss] It looks like you're trying to use tailwindcss directly as a PostCSS plugin. The PostCSS plugin has moved to a separate package, so to continue using Tailwind CSS with PostCSS you'll need to install @tailwindcss/postcss and update your PostCSS configuration.
<-- it's a typically new TailwindCSS v4 warning message. Use@tailwindcss/postcss
instead oftailwindcss
. – rozsazoltan Commented Mar 22 at 23:30