You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Nativewind在React Native集成TailwindCSS时遇异步插件报错

解决Nativewind集成TailwindCSS时的"Use process(css).then(cb) to work with async plugins"报错

这个错误通常由版本不兼容或配置文件错误导致,以下是具体修复步骤:

1. 确认Nativewind与TailwindCSS版本匹配

Nativewind v2 必须搭配 TailwindCSS v3.x,v1 对应 TailwindCSS v2.x。执行以下命令确保版本正确:

# 卸载现有不兼容依赖
npm uninstall nativewind tailwindcss

# 安装兼容版本
npm install nativewind tailwindcss@3.x

2. 检查并修复Tailwind配置文件

确保项目根目录下的 tailwind.config.js 内容正确,需包含你的组件路径:

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
    "./App.{js,jsx,ts,tsx}",
    "./screens/**/*.{js,jsx,ts,tsx}" // 覆盖HomeScreen所在目录
  ],
  theme: {
    extend: {},
  },
  plugins: [],
}

3. 验证Babel配置

检查项目根目录的 babel.config.js,确保已添加Nativewind的Babel插件:

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  plugins: ["nativewind/babel"],
};

4. 清理React Native缓存

缓存问题也可能引发该错误,执行命令重置缓存:

npx react-native start --reset-cache

完成以上步骤后,重新运行项目即可解决该报错。

内容的提问来源于stack exchange,提问作者Muhammad Umair Zahid

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.16 15:27:00