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

Nativewind/Babel报错:需使用process(css).then(cb)处理异步插件

Nativewind/Babel组件报错:Use process(css).then(cb) to work with async plugins 解决办法

Bug描述

涉及Nativewind/Babel组件,触发错误提示:Use process(css).then(cb) to work with async plugins

复现步骤

  • 使用expo/nativewind创建新的React Native项目
  • 按照官方文档完成nativewind配置
  • 启动项目后触发上述错误

期望行为

应用正常加载,样式正常显示

可行解决方案

  1. 匹配版本兼容性
    Nativewind v4要求PostCSS版本为8.x,若安装了过高版本(比如PostCSS v9)会触发该错误。执行以下命令安装兼容版本:
npm install nativewind@latest postcss@8.4.38
# yarn用户执行:
yarn add nativewind@latest postcss@8.4.38
  1. 修正PostCSS配置
    确保项目根目录的postcss.config.js配置正确,避免同步语法问题:
module.exports = {
  plugins: [
    require('tailwindcss'),
    require('nativewind/postcss'),
  ],
};
  1. 检查Babel配置
    确认babel.config.js中nativewind插件配置无误:
module.exports = function (api) {
  api.cache(true);
  return {
    presets: ['babel-preset-expo'],
    plugins: ["nativewind/babel"],
  };
};
  1. 清除缓存重启项目
    清除Expo缓存并重启,确保配置生效:
npx expo start --clear

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.18 20:22:32