React Native Expo 建设非常缓慢

React Native Expo building very slowly

我最近注意到我的构建时间显着增加,有时需要整整一分钟才能加载。在控制台上,我仍然可以很快看到 "Building JavaScript bundle: finished",但屏幕需要更长的时间来刷新。会发生这样的事情有什么原因吗?

尝试在您的开发机器上的模拟器中使用 Expo,并确定它花费的时间是否与您的设备一样长:

  • 如果它比您的测试设备快,那么您应该检查 测试设备上的网络连接
  • 如果它和测试设备一样慢,那么您可以尝试删除 node_modules 并使用 'npm install' 或 'yarn' 重新安装它们。 Expo 将与所有其他包一起重新下载。

就我而言,这是一个不同的解决方案。

我关注了 the instructions given by jimmylee on the Expo SDK forums,它说:

If you are behind a VPN, try disabling the VPN.

If you are using windows 10, run CMD on your machine and type ipconfig. Take a look at the first Ethernet Adapter. If it doesn’t say Ethernet Adapter Ethernet it means Expo is taking the IP address of something else.

To fix this, go to network connections and disable the adapter that it should not be pointing at.

Connect your computer to the network and your phone to the same network. Restart Expo.

因此,转到“设置”>“网络和 Internet”。

单击更改适配器选项:

然后禁用不需要的以太网:

然后重启 Expo。

如果已建立连接但捆绑构建速度很慢 - 尝试断开系统和移动设备这两个设备的网络连接,然后重新连接。另外,不要忘记清除 'recently in development' 项目并重新启动项目。 它肯定会大大提高构建速度,特别是对于 windows 效果非常好。

我遇到了同样的问题。

我在多个设备上使用了 expo,显然它也取决于设备,即它是否能够处理它。

其次,对于慢速设备,我想出了一个解决方案。

我刚刚关闭了 fast Refresh

Fast Refresh 密切关注开发方面,并在我们进行更改时不断重新加载。

通过停用它,我们需要自己刷新应用程序。但这对我有帮助。

由于多次刷新和连续捆绑,expo 变慢(对我来说)因此禁用此功能可能会有所帮助(事实上对我帮助很大)。

执行此操作的步骤;

在您的 expo go 应用中,摇动您的设备。将打开一个选项面板。

将有一个选项 disable fast refresh。只需单击它即可完成。