【问题标题】:React Native: Can't run app on iOS correctly "Failed to load bundle(http://localhost:8081/index.bundle?"React Native:无法在 iOS 上正确运行应用程序“加载包失败(http://localhost:8081/index.bundle?”
【发布时间】:2018-08-15 23:49:15
【问题描述】:

在尝试运行 react 原生 iOS 应用程序时,我收到一个带有错误的红页。这是我在 iOS 屏幕上遇到的以下错误。

 Failed to load bundle(http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false) with error:(Unable to resolve module ./node_modules/react-native/src/constants/screens from/Users/username/Desktop/mobile/App.js: The module ./node_modules/react-native/src/constants/screens could not be found from /Users/username/Desktop/mobile/App.js. Indeed, none of these files exist:

/Users/username/Desktop/mobile/node_modules/react-native/src/constants/screens(.native||.ios.jsx|.native.jsx|.jsx|.ios.js|.native.js|.js|.ios.js|.native.js|.js|.ios.json|.native.json|.json)`

 /Users/username/Desktop/mobile/node_modules/react-native/src/constants/screens/index(.native||.ios.jsx|.native.jsx|.jsx|.ios.js|.native.js|.js|.ios.js|.native.js|.js|.ios.json|.native.json|.json) (null))

__38-[RCTCxxBridge loadSource:onProgress:]_block_invoke.245
    RCTCxxBridge.mm:420
___ZL36attemptAsynchronousLoadOfBundleAtURLP5NSURLU13block_pointerFvP18RCTLoadingProgressEU13block_pointerFvP7NSErrorP9RCTSourceE_block_invoke.118
__80-[RCTMultipartDataTask URLSession:streamTask:didBecomeInputStream:outputStream:]_block_invoke
-[RCTMultipartStreamReader emitChunk:headers:callback:done:]
-[RCTMultipartStreamReader readAllPartsWithCompletionCallback:progressCallback:]
-[RCTMultipartDataTask URLSession:streamTask:didBecomeInputStream:outputStream:]
__88-[NSURLSession delegate_streamTask:didBecomeInputStream:outputStream:completionHandler:]_block_invoke
__NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__
-[NSBlockOperation main]
-[__NSOperationInternal _start:]
_dispatch_client_callout
_dispatch_block_invoke_direct
_dispatch_client_callout
_dispatch_block_invoke_direct
dispatch_block_perform
__NSOQSchedule_f
_dispatch_client_callout
_dispatch_continuation_pop
_dispatch_async_redirect_invoke
_dispatch_root_queue_drain
_dispatch_worker_thread3
_pthread_wqthread
start_wqthread

我尝试通过查看其他 stackoverflow 帖子来解决此问题。但是,到目前为止,没有一个解决方案对我有用。老实说,我很困惑,不知道该怎么办。感谢您提供任何帮助或建议。

【问题讨论】:

  • 您能添加您的 RN 版本,或许还有您的项目依赖项吗?

标签: javascript ios react-native


【解决方案1】:

快速修复:npm add @babel/runtime

然后:rm -rf ios/build/;杀死 $(lsof -t -i:8081); react-native run-ios

【讨论】:

  • 该脚本做了什么,因为我显然不明白它的用途,我用它来修复它没有修复的其他东西,并且知道我收到一个错误说“不能连接到开发服务器
  • 嘿@prog 第一行添加 babel/runtime 包,第二行清除旧版本并终止端口上的任何操作,最后重新开始运行
猜你喜欢
  • 2018-11-03
  • 2018-05-23
  • 2020-07-23
  • 1970-01-01
  • 2019-12-21
  • 1970-01-01
  • 2015-07-24
  • 1970-01-01
  • 2019-03-22
相关资源
最近更新 更多