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

React Native集成Nativewind/Tailwind CSS遇iOS打包错误求助

解决Nativewind v2 + Tailwind CSS v3.3.x的打包报错问题

报错信息

Started Metro Bundler
iOS Bundling failed 1903ms
App.js: C:\Users\Tomiwa Kukoyi\Desktop\infocrypto\infocrypto\App.js: Use process(css).then(cb) to work with async plugins

当前配置文件

tailwind.config.js

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: ["./App.{js,jsx,ts,tsx}"],
  theme: {
    extend: {},
  },
  plugins: [],
};

babel.config.js

// babel.config.js
module.exports = {
  presets: ["babel-preset-expo"],
  plugins: ["nativewind/babel"],
};

package.json

{
  "name": "infocrypto",
  "version": "1.0.0",
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web"
  },
  "dependencies": {
    "babel-preset-expo": "^9.5.2",
    "expo": "~49.0.11",
    "expo-status-bar": "~1.6.0",
    "nativewind": "^2.0.11",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-native": "0.72.4",
    "react-native-web": "~0.19.6"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "tailwindcss": "^3.3.3"
  },
  "private": true
}

解决步骤

  • 降级Tailwind CSS到兼容版本:Nativewind v2暂不支持Tailwind CSS v3.3.x的异步插件处理,执行以下命令安装3.2.7版本:
    yarn add tailwindcss@3.2.7 --dev
    
  • 清除缓存并重启Metro:停止当前运行的Metro服务,执行:
    expo start --clear
    

现有配置文件无需修改,按上述步骤操作后即可解决打包报错问题。

内容的提问来源于stack exchange,提问作者Tomiwa Kukoyi

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.09 22:22:32