使用Nativewind开发React Native遇iOS打包错误求助
解决Nativewind "Use process(css).then(cb) to work with async plugins" 错误
这个错误大多是Nativewind v4与PostCSS配置不兼容导致的,以下是几个可行的解决步骤:
检查Nativewind及依赖版本
确认你安装的是Nativewind v4,它要求tailwindcss@^3.3.5和postcss@^8.4.31以上版本。执行npm list nativewind tailwindcss postcss查看版本,若版本不匹配,重新安装对应版本:npm install nativewind@latest tailwindcss@latest postcss@latest修正PostCSS配置文件
Nativewind v4使用异步PostCSS插件,你的postcss.config.js必须用异步函数导出配置,不能用同步对象:module.exports = async () => ({ plugins: { tailwindcss: {}, 'nativewind/postcss': {}, }, });注意不要遗漏
nativewind/postcss插件,且必须包裹在异步函数里。清除缓存并重启Metro
旧缓存可能导致配置不生效,执行以下命令彻底清除缓存并重启开发服务器:npx expo start --clear确认Expo SDK版本
Nativewind v4要求Expo SDK 49及以上版本,若你的SDK版本低于49,需要升级Expo:npx expo upgrade检查组件中的样式语法
确保App.tsx或其他组件中没有错误的Tailwind类名,比如使用了Nativewind不支持的桌面端专属指令,或者拼写错误的类名。
内容的提问来源于stack exchange,提问作者Gustavo Cortinez
相关产品推荐
相关产品推荐

