开发者使用 Expo 时遇到的常见开发错误列表。
本页概述了开发者使用 Expo 时经常遇到的错误列表。对于每个错误,第一个项目符号提供了错误发生原因的解释,第二个项目符号包含调试建议。如果你认为这里有错误,我们欢迎并鼓励你 创建 PR!
¥This page outlines a list of errors that are commonly encountered by developers using Expo. For each error, the first bullet provides an explanation for why the error occurs and the second bullet contains debugging suggestions. If there is an error you think belongs here, we welcome and encourage you to create a PR!
¥Metro bundler ECONNREFUSED 127.0.0.1:19001
错误导致无法连接到本地开发服务器。
¥An error is preventing the connection to your local development server.
运行 rm -rf .expo
以清除本地状态。检查影响你当前连接的网络的防火墙或 proxies。
¥Run rm -rf .expo
to clear your local state. Check for firewalls or proxies affecting the network you are currently connected to.
¥Module AppRegistry is not a registered callable module (calling runApplication)
代码中的错误导致 JavaScript 包无法在启动时执行。
¥An error in your code is preventing the JavaScript bundle from being executed on startup.
尝试运行 npx expo start --no-dev --minify
在本地重现生产 JS 包。如果可能,请连接你的设备并通过 Android Studio 或 Xcode 访问设备日志。设备日志包含更详细的堆栈跟踪和信息。检查 Babel 配置是否有任何更改或错误。在极少数情况下,此问题可能是由于 Metro JavaScript 压缩器与应用中的某些代码 (更多信息) 不兼容造成的。
¥Try running npx expo start --no-dev --minify
to reproduce the production JS bundle locally. If possible, connect your device and access the device logs via Android Studio or Xcode. Device logs contain much more detailed stacktraces and information. Check to see if you have any changes or errors in your Babel configuration. In some rare cases, this issue could be caused by incompatibility between the Metro JavaScript minifier and certain code in your app (more information).
¥npm ERR! No git binary found in $PATH
要么你没有安装 git,要么你的 $PATH
.conf 中没有正确配置 git。
¥Either you do not have git installed or it is not properly configured in your $PATH
.
安装 git(如果你还没有)。否则,请根据你的操作系统检查如何在 $PATH
中设置它。
¥Install git if you have not already. Otherwise, check how to set it in your $PATH
based on your OS.
¥XX.X.X is not a valid SDK version
你正在运行的 SDK 版本已被弃用,不再受支持。
¥The SDK version you are running has been deprecated and is no longer supported.
升级你的项目 到支持的 SDK 版本。如果你使用的是受支持的版本并看到此消息,则需要更新你的 Expo Go 应用。
¥Upgrade your project to a supported SDK version. If you are using a supported version and see this message, you'll need to update your Expo Go app.
¥React Native version mismatch
在你的终端中运行的开发服务器打包了与你的设备或模拟器中的应用不同版本的 React Native。
¥The development server running in your terminal is bundling a different version of React Native than the app in your device or simulator.
调整你的 react-native 版本 通过检查 app.json 和 package.json 中的版本
¥Align your versions of react-native by checking the versions in your app.json and package.json
¥Application has not been registered
你的应用的原生部分和 JS 部分中注册的 AppKey 不匹配。
¥There is a mismatch between the AppKey registered in the native and JS portion of your app.
对齐你的 AppKey 与你项目的原生部分。
¥Align your AppKey with the native side of your project.
¥Application not behaving as expected