我刚刚从 RN 59 升级到 RN 60.2 并且 react-native run-ios
用于启动 Metro Bundler 然后打开模拟器并运行应用程序,现在不再这样做了。它们现在需要是单独的命令。
我不确定如何将 react-native start
和 react-native run-ios
作为一个命令运行,因为 start
确实不会自行终止,因此不会告诉 run-ios 运行。
这是我目前拥有的脚本:
"scripts": {
"ios": "react-native run-ios --simulator=\"iPhone 11\"",
"rename": "node ./bin/rename.js",
"start": "react-native start",
}
我的想法是这样的:
react-native start && react-native run-ios
到目前为止,最好的替代方法是向后运行它们并让它构建应用程序,然后启动 Metro Bundler:
react-native run-ios && react-native start
这会导致模拟器首先启动并显示 bundler 未在线的错误消息,然后运行服务器,然后让我重新加载模拟器。这不太理想。
是否有替代方法?
最佳答案
好吧,试试这个方法
"custom":"react-native run-android && react-native start"
然后,一旦您进入 package.json 所在的项目根目录,系统就会指示您在终端中运行“npm run custom”。
关于ios - 在一个命令中运行 react-native run-ios 和 react-native start?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58406684/