You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native iOS/Expo构建失败求助:多报错问题排查

Expo iOS构建失败:AppRegistry.runApplication()模块未注册

我的设备上Expo构建失败,但其他开发者的电脑可正常运行,二者仅iOS模拟器版本不同,但我们认为这并非问题根源。

执行expo start -c并在iOS上运行时,构建失败并出现以下报错:

at node_modules/react-native/Libraries/Core/ExceptionsManager.js:95:17 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:141:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:39 in handleError
at node_modules/@react-native/polyfills/error-guard.js:49:36 in ErrorUtils.reportFatalError
at node_modules/metro-runtime/src/polyfills/require.js:237:40 in guardedLoadModule
at http://192.168.0.62:19000/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false&strict=false&minify=false:null in global code

Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). Module has not been registered as callable. Registered callable JavaScript modules (n = 11): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, JSDevSupportModule, HMRClient, RCTEventEmitter.
        A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:95:17 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:141:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:39 in handleError
at node_modules/@react-native/polyfills/error-guard.js:49:36 in ErrorUtils.reportFatalError

Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). Module has not been registered as callable. Registered callable JavaScript modules (n = 11): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, JSDevSupportModule, HMRClient, RCTEventEmitter.
        A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:95:17 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:141:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:39 in handleError
at node_modules/@react-native/polyfills/error-guard.js:49:36 in ErrorUtils.reportFatalError

我已尝试执行npm install、清除缓存、重置文件路径以及重新构建Expo,但问题仍未解决。


排查思路与解决方案
  • 对齐Node.js版本:确认你的Node.js版本和其他正常运行的开发者完全一致,不同版本可能导致依赖安装差异,用nvm切换到相同版本后重新执行npm install。
  • 同步Expo CLI版本:执行expo --version对比其他开发者的版本,不一致的话升级/降级到对应版本,再重启项目。
  • 深度清理缓存:除了expo start -c,手动删除以下内容后重装依赖:
    • 项目根目录的node_modules、package-lock.json/yarn.lock
    • 本地Expo缓存:~/.expo/cache
    • Metro缓存:Mac执行rm -rf $TMPDIR/metro-*,Windows执行del %TMPDIR%\metro-*
      之后重新运行npm install和expo start -c。
  • 检查入口文件配置:核对app.json或app.config.js里的entryPoint字段,确保指向正确的入口文件(如App.js),和其他开发者的配置保持一致。
  • 排查入口初始化错误:在应用入口文件顶部添加console.log('Entry loaded'),启动后查看Metro终端是否输出该日志。如果没有,说明入口未被正确加载,逐步注释代码排查语法错误或依赖导入问题。
  • 重置iOS模拟器:打开模拟器后选择Hardware > Erase All Content and Settings,清除所有数据后重新运行项目。
  • 检查依赖冲突:执行npm ls查看react-native、expo相关包的版本冲突,用npm dedupe整理依赖,或删除冲突包后重装。

内容的提问来源于stack exchange,提问作者Rohit Sehgal

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.02 12:15:33