vue3使用tailwindcss报错问题

  1. npm create vite@latest

  2. npm install -D tailwindcss postcss autoprefixer

  3. npx tailwindcss init
    4. ·不过执行 npx tailwindcss init 的时候控制台就报错了

    js 复制代码
    PS E:\vite-demo> npx tailwindcss init
    npm ERR! cb.apply is not a function
    npm ERR! A complete log of this run can be found in:
    1. 那就手动创建 tailwind.config.js文件和postcss.config.js文件
    js 复制代码
    	// tailwind.config.js
    	/** @type {import('tailwindcss').Config} */
    	module.exports = {
    	  content: ["./src/**/*.{html,js}"],
    	  theme: {
    	    extend: {},
    	  },
    	  plugins: [],
    	}
    js 复制代码
    // postcss.config.js
    module.exports = {
      plugins: {
        tailwindcss: {},
        autoprefixer: {},
      }
    }

    然后再style.css引入

    css 复制代码
    @tailwind base;
    @tailwind components;
    @tailwind utilities;

    npm install
    报错

    js 复制代码
    [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.
  4. 重新安装 npm install @tailwindcss/postcss

js 复制代码
	import postcssTailwind from '@tailwindcss/postcss'; 
		import autoprefixer from 'autoprefixer'; 
		export default { 
		    plugins: [ postcssTailwind, autoprefixer ]
		};

注意: 要看清版本 现在安装的tailwindcss 是4.x 官网是3.x

地址:https://tailwindcss.com/

相关推荐
skylar012 分钟前
小白1分钟安装flash-attn
开发语言·python
默子昂20 分钟前
ollama 自定义ui
开发语言·python·ui
#麻辣小龙虾#36 分钟前
基于vue3.0开发一款【固废与废气运维管理系统】(支持源码)
前端·vue.js·vue3
Cosolar40 分钟前
Docsify零构建文档站完全指南:从快速搭建到企业级部署
前端·开源·github
weixin_471383031 小时前
Taro-02-页面路由
前端·taro
星栈独行1 小时前
Makepad 应用如何读文件、调接口、保存数据
前端·程序人生·ui·rust·github
赴生-2 小时前
C++进阶 C++11(下)
开发语言·c++
一 乐2 小时前
家政服务管理系统|基于springboot + vue家政服务管理系统(源码+数据库+文档)
java·数据库·vue.js·spring boot·论文·毕设·家政服务管理系统
IT_陈寒2 小时前
Vite热更新失效?可能你在用Windows
前端·人工智能·后端
烬羽2 小时前
后端返回的 JSON 字符串,浏览器怎么"看懂"的?——Ajax 全链路拆解
javascript