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配置
- 启动项目后触发上述错误
期望行为
应用正常加载,样式正常显示
可行解决方案
- 匹配版本兼容性
Nativewind v4要求PostCSS版本为8.x,若安装了过高版本(比如PostCSS v9)会触发该错误。执行以下命令安装兼容版本:
npm install nativewind@latest postcss@8.4.38 # yarn用户执行: yarn add nativewind@latest postcss@8.4.38
- 修正PostCSS配置
确保项目根目录的postcss.config.js配置正确,避免同步语法问题:
module.exports = { plugins: [ require('tailwindcss'), require('nativewind/postcss'), ], };
- 检查Babel配置
确认babel.config.js中nativewind插件配置无误:
module.exports = function (api) { api.cache(true); return { presets: ['babel-preset-expo'], plugins: ["nativewind/babel"], }; };
- 清除缓存重启项目
清除Expo缓存并重启,确保配置生效:
npx expo start --clear
内容的提问来源于stack exchange,提问作者danilopx
相关产品推荐
相关产品推荐

