react-native 无法在新的CLI项目中使用Hermes引擎,

rqcrx0a6  于 24天前  发布在  React
关注(0)|答案(2)|浏览(17)

从头开始创建一个新的cli项目,该项目应使用hermes作为默认引擎,如果没有SourceCode模块错误消息,应用程序将回退到web socket扩展。我唯一的线索是缺失的SourceCode模块错误消息,但我不确定它是如何发生的,也不知道如何解决它。

我已经尝试过重新安装node、ruby和cocoapods,然后创建一个新的cli项目,但没有任何改变。但是,如果我安装基本的expo开发构建,hermes可以正常工作,没有任何问题。

我认为原因是操作系统(macOS Sonoma 14.6.1)中缺少、过时或损坏的依赖项。这个bug间接影响了我使用redux-devtoolsreact-native-debugger进行开发的能力。如果有人能帮助我找到根本原因,我将非常感激。

谢谢!

k4ymrczo

k4ymrczo1#

嘿,@arstropica,你可以尝试运行:

npx @react-native-community/cli@latest init AwesomeProject --version latest

并报告结果吗?

e0bqpujr

e0bqpujr2#

npx @react-native-community/cli@latest init AwesomeProject --version latest
No problems with the installation.

Downloading template
✔ Copying template
✔ Processing template
✔ Installing dependencies
✔ Do you want to install CocoaPods now? Only needed if you run your project in Xcode directly … yes
✔ Installing Ruby Gems
✔ Installing CocoaPods dependencies  (this may take a few minutes)
info 💡 To enable automatic CocoaPods installation when building for iOS you can create react-native.config.js with automaticPodsInstallation field. 
For more details, see https://github.com/react-native-community/cli/blob/main/docs/projects.md#projectiosautomaticpodsinstallation
            
✔ Initializing Git repository

  
  Run instructions for Android:
    • Have an Android emulator running (quickest way to get started), or a device connected.
    • cd "/Users/estate/dev/code/react/AwesomeProject" && npx react-native run-android
  
  Run instructions for iOS:
    • cd "/Users/estate/dev/code/react/AwesomeProject"
    
    • npx react-native run-ios
    - or -
    • Open AwesomeProject/ios/AwesomeProject.xcworkspace in Xcode or run "xed -b ios"
    • Hit the Run button
    
  Run instructions for macOS:
    • See https://aka.ms/ReactNativeGuideMacOS for the latest up-to-date instructions.

But when I build and run the app in Xcode, it launches with the same error as previously reported:

Running application AwesomeProject ({
    initialProps =     {
        concurrentRoot = 0;
    };
    rootTag = 1;
})
Invalidating <RCTCxxBridge: 0x107f11c70> (parent: <RCTBridge: 0x600003038000>, executor: RCTWebSocketExecutor)
Thread Performance Checker: Thread running at User-interactive quality-of-service class waiting on a thread without a QoS class specified. Investigate ways to avoid priority inversions
PID: 39266, TID: 6761176
Backtrace
=================================================================
3   CFNetwork                           0x00007ff8048e6dda estimatedPropertyListSize + 27583
4   CFNetwork                           0x00007ff804769d17 cfnTranslateCFError + 2029
5   libdispatch.dylib                   0x0000000105d469f7 _dispatch_client_callout + 8
6   libdispatch.dylib                   0x0000000105d48095 _dispatch_once_callout + 66
7   CFNetwork                           0x00007ff804769ceb cfnTranslateCFError + 1985
8   CFNetwork                           0x00007ff8048e6c82 estimatedPropertyListSize + 27239
9   libdispatch.dylib                   0x0000000105d469f7 _dispatch_client_callout + 8
10  libdispatch.dylib                   0x0000000105d48095 _dispatch_once_callout + 66
11  CFNetwork                           0x00007ff8048e6bab estimatedPropertyListSize + 27024
12  CFNetwork                           0x00007ff8048e6bf6 estimatedPropertyListSize + 27099
13  libdispatch.dylib                   0x0000000105d469f7 _dispatch_client_callout + 8
14  libdispatch.dylib                   0x0000000105d48095 _dispatch_once_callout + 66
15  CFNetwork                           0x00007ff8048e6be5 estimatedPropertyListSize + 27082
16  CFNetwork                           0x00007ff8047b09a0 _CFStreamErrorFromCFError + 189030
17  CoreFoundation                      0x00007ff800412c57 _CFStreamOpen + 135
18  AwesomeProject                      0x00000001038a966d -[SRProxyConnect _openConnection] + 189
19  AwesomeProject                      0x00000001038a89dc -[SRProxyConnect _configureProxy] + 988
20  AwesomeProject                      0x00000001038a813b -[SRProxyConnect openNetworkStreamWithCompletion:] + 91
21  AwesomeProject                      0x00000001038acaf8 -[SRWebSocket open] + 744
22  AwesomeProject                      0x00000001030d4a4d -[RCTReconnectingWebSocket start] + 173
23  AwesomeProject                      0x00000001030bcbfb -[RCTPackagerConnection init] + 507
24  AwesomeProject                      0x00000001030bc9dc __49+[RCTPackagerConnection sharedPackagerConnection]_block_invoke + 28
25  libdispatch.dylib                   0x0000000105d469f7 _dispatch_client_callout + 8
26  libdispatch.dylib                   0x0000000105d48095 _dispatch_once_callout + 66
27  AwesomeProject                      0x00000001030bc98e +[RCTPackagerConnection sharedPackagerConnection] + 78
28  AwesomeProject                      0x000000010315f8ce -[RCTDevSettings initialize] + 142
29  AwesomeProject                      0x00000001030a5ec8 -[RCTModuleData _initializeModule] + 104
30  AwesomeProject                      0x00000001030a574e -[RCTModuleData setUpInstanceAndBridge:] + 2894
31  AwesomeProject                      0x00000001030a7670 -[RCTModuleData instance] + 1408
32  AwesomeProject                      0x0000000103041f86 -[RCTCxxBridge moduleForName:lazilyLoadIfNecessary:] + 790
33  AwesomeProject                      0x0000000103042460 -[RCTCxxBridge moduleForClass:] + 80
34  AwesomeProject                      0x0000000103163598 -[RCTBridge(RCTDevSettings) devSettings] + 56
35  AwesomeProject                      0x0000000103047aa0 -[RCTCxxBridge executeSourceCode:withSourceURL:sync:] + 320
36  AwesomeProject                      0x0000000103040a97 __21-[RCTCxxBridge start]_block_invoke.212 + 151
37  libdispatch.dylib                   0x0000000105d45747 _dispatch_call_block_and_release + 12
38  libdispatch.dylib                   0x0000000105d469f7 _dispatch_client_callout + 8
39  libdispatch.dylib                   0x0000000105d5aa97 _dispatch_root_queue_drain + 1047
40  libdispatch.dylib                   0x0000000105d5b3b5 _dispatch_worker_thread2 + 277
41  libsystem_pthread.dylib             0x0000000105ca9b43 _pthread_wqthread + 262
42  libsystem_pthread.dylib             0x0000000105ca8acf start_wqthread + 15
Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'SourceCode' could not be found. Verify that a module by this name is registered in the native binary. Bridgeless mode: false. TurboModule interop: false. Modules loaded: {"NativeModules":["PlatformConstants","DevSettings","LogBox","Timing","SettingsManager","AppState"],"TurboModules":[],"NotFound":["NativePerformanceObserverCxx","NativePerformanceCxx","NativeReactNativeFeatureFlagsCxx","SourceCode"]}, js engine: hermes
Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'SourceCode' could not be found. Verify that a module by this name is registered in the native binary. Bridgeless mode: false. TurboModule interop: false. Modules loaded: {"NativeModules":["PlatformConstants","DevSettings","LogBox","Timing","SettingsManager","AppState"],"TurboModules":[],"NotFound":["NativePerformanceObserverCxx","NativePerformanceCxx","NativeReactNativeFeatureFlagsCxx","SourceCode"]}, js engine: hermes
Unbalanced calls start/end for tag 1
Unbalanced calls start/end for tag 19
Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). Module has not been registered as callable. Bridgeless Mode: false. Registered callable JavaScript modules (n = 9): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, HMRClient.
          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., js engine: hermes
Running application AwesomeProject ({
    initialProps =     {
        concurrentRoot = 0;
    };
    rootTag = 11;
})

I also confirmed that SourceCode is present in the project, just not sure why Turbo Native Modules can't find it.

相关问题