如何解决:TypeError:null 不是对象(评估“AgoraRtcChannelModule.prefix”)?

Posted

技术标签:

【中文标题】如何解决:TypeError:null 不是对象(评估“AgoraRtcChannelModule.prefix”)?【英文标题】:How do I fix: TypeError: null is not an object (evaluating 'AgoraRtcChannelModule.prefix')? 【发布时间】:2021-05-20 21:09:15 【问题描述】:

每次我将 RtcEngine 导入我的应用程序 (import RtcEngine from 'react-native-agora';) 时,我都会收到以下错误:

TypeError: null is not an object (evaluating 'AgoraRtcChannelModule.prefix')
at node_modules\react-native\Libraries\LogBox\LogBox.js:148:8 in registerError
at node_modules\react-native\Libraries\LogBox\LogBox.js:59:8 in errorImpl
at node_modules\react-native\Libraries\LogBox\LogBox.js:33:4 in console.error
at node_modules\expo\build\environment\react-native-logs.fx.js:27:4 in error
at node_modules\react-native\Libraries\Core\ExceptionsManager.js:104:6 in reportException
at node_modules\react-native\Libraries\Core\ExceptionsManager.js:171:19 in handleException
at node_modules\react-native\Libraries\Core\setUpErrorHandling.js:24:6 in handleError
at node_modules\expo-error-recovery\build\ErrorRecovery.fx.js:12:21 in ErrorUtils.setGlobalHandler$argument_0
at node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:62:36 in tryCatch
at node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:288:29 in invoke
at node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:62:36 in tryCatch
at node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:152:27 in invoke
at node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:162:18 in Promise.resolve.then$argument_0
at node_modules\react-native\node_modules\promise\setimmediate\core.js:37:13 in tryCallOne
at node_modules\react-native\node_modules\promise\setimmediate\core.js:123:24 in setImmediate$argument_0
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:130:14 in _callTimer
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:181:14 in _callImmediatesPass
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:441:30 in callImmediates
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:387:6 in __callImmediates
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:135:6 in __guard$argument_0
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:364:10 in __guard
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:134:4 in flushedQueue
at [native code]:null in flushedQueue
at [native code]:null in invokeCallbackAndReturnFlushedQueue

Invariant Violation: "main" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.
at node_modules\react-native\Libraries\LogBox\LogBox.js:148:8 in registerError
at node_modules\react-native\Libraries\LogBox\LogBox.js:59:8 in errorImpl
at node_modules\react-native\Libraries\LogBox\LogBox.js:33:4 in console.error
at node_modules\expo\build\environment\react-native-logs.fx.js:27:4 in error
at node_modules\react-native\Libraries\Core\ExceptionsManager.js:104:6 in reportException
at node_modules\react-native\Libraries\Core\ExceptionsManager.js:171:19 in handleException
at node_modules\react-native\Libraries\Core\setUpErrorHandling.js:24:6 in handleError
at node_modules\expo-error-recovery\build\ErrorRecovery.fx.js:12:21 in ErrorUtils.setGlobalHandler$argument_0
at node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:62:36 in tryCatch
at node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:288:29 in invoke
at node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:62:36 in tryCatch
at node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:152:27 in invoke
at node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:162:18 in Promise.resolve.then$argument_0
at node_modules\react-native\node_modules\promise\setimmediate\core.js:37:13 in tryCallOne
at node_modules\react-native\node_modules\promise\setimmediate\core.js:123:24 in setImmediate$argument_0
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:130:14 in _callTimer
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:181:14 in _callImmediatesPass
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:441:30 in callImmediates
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:387:6 in __callImmediates
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:135:6 in __guard$argument_0
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:364:10 in __guard
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:134:4 in flushedQueue
at [native code]:null in flushedQueue
at [native code]:null in invokeCallbackAndReturnFlushedQueue

注意:这是没有任何调用的。

对此的任何帮助将不胜感激。我对 react-native 和 javascript 还很陌生,所以我希望我已经提供了足够的信息。

【问题讨论】:

【参考方案1】:

我认为你没有正确使用 React Native。

我可能会建议阅读文档并尝试最新版本:

QuickStart Guide

P.S:Agora React-Native SDK 不支持 Expo。

【讨论】:

【参考方案2】:

Agora SDK 是一个原生模块,我看到您正在尝试将它与 expo 一起使用。 Expo 托管工作流不支持原生模块,您可以弹出到裸工作流或使用 react-native CLI。

更新: Expo 现在支持使用原生模块,而无需使用自定义开发客户端弹出到裸 wofklow,您可以通过 Agora here 了解更多关于使用它们的信息。

【讨论】:

以上是关于如何解决:TypeError:null 不是对象(评估“AgoraRtcChannelModule.prefix”)?的主要内容,如果未能解决你的问题,请参考以下文章

TypeError:null 不是对象(评估'_ReanimatedModule.default.createNode')

“TypeError:null 不是对象(评估‘RCTVideoInstance.Constants’)”

TypeError:null 不是对象(评估 ''this.state.torchon')

TypeError:null 不是对象(评估'RNRandomBytes.seed')React Native

TypeError:null 不是对象(评估'this.state.initialPosition') - React Native

TypeError:null 不是对象(评估“storagedTechs.split”)