如何阻止EAS本地构建时在新终端窗口启动Metro构建
解决EAS本地构建自动启动Metro的问题
直接给两个可行的解决办法,选一个用就行:
方法一:命令行添加参数
在你执行的构建命令末尾加上--no-start,强制跳过启动Metro的步骤,修改后的命令如下:
eas build --local --clear-cache --profile production --platform ios --non-interactive --no-start eas build --local --clear-cache --profile preview --platform ios --non-interactive --no-start
方法二:修改eas.json配置
在preview和production的构建配置里添加"start": false,以后用这两个profile构建时就不会自动启动Metro了,修改后的eas.json如下:
{ "cli": { "version": ">= 5.9.1" }, "build": { "development": { "developmentClient": true, "distribution": "internal", "android": { "gradleCommand": ":app:assembleDebug" }, "ios": { "buildConfiguration": "Debug" } }, "preview": { "distribution": "internal", "ios": {}, "start": false }, "production": { "distribution": "store", "ios": { "autoIncrement": "version" }, "start": false } }, "submit": { "production": {} } }
原理就是EAS CLI默认会在本地构建时启动开发服务器(Metro),但生产/预览构建完全不需要这一步,通过上面的配置或参数就能直接禁用这个行为。
内容的提问来源于stack exchange,提问作者David Dehghan
相关产品推荐
相关产品推荐

