React Native - 模块 AppRegistry 不是已注册的可调用模块

React Native - Module AppRegistry is not a registered callable module

每当我升级到 react-native 0.61.5 以上时,我都会收到错误 Module AppRegistry is not a registered callable module。一旦我降级回 0.61.5,它又可以正常工作了。

20 年 11 月 14 日更新 我尝试了答案 killall -9 node,但收到错误 bash: killall: command not found。这可能是一个非常新手的错误,我需要从不同的路径安装一些东西或 运行 命令

更新 12/28/20 - 回应@dhruv soni.....下面是我的 index.js 文件,其中 AppRegistry.registerComponent 被调用:

21 年 1 月 23 日更新 - 我使用“React Native Upgrade Helper”进行升级...三次检查一切正确。 问题只发生在 Android 上(而不是 IOS)....但它在 Android Studio 上构建良好...错误只发生在 react-native run-android 上。 我使用了很多第 3 方库,所以我猜它与此有关

杀死所有节点进程并启动服务器和运行应用程序

  • 运行命令killall node
  • 运行 taskkill /f /im node.exe 如果进程仍然存在
  • 运行命令yarn start --reset-cache
  • 运行 命令 react-native run-iosreact-native run-android

通过仔细检查我在 RN upgrade、运行、watchman watch-del-allreact-native start --reset-cache 期间是否正确修改了所有文件,解决了我这边的问题。然后在 android 上,构建 -> 清理。然后它起作用了!叹息

具体解决你的问题

我发现 appContainer 的初始化错误。您可以按以下方式修复

const AppContainer = createAppContainer(SignedInTabNav);

class App extends React.Component {
  render() {
    return <AppContainer />;
  }
}

export default App;

我可能是错的,但就我而言,每次我安装新的 npm 包时都会发生这种情况,也许不确定,但我只用 iOS 面对这个问题,所以每次我遇到这个问题时我都会关注这些步骤。

  • killall -9 节点
  • 删除包-lock.json
  • 删除 node_module 文件夹
  • 删除 pods 文件夹
  • 删除 pod-lock 文件。
  • npm i
  • npm pod-install ios
  • npm 启动 --reset-cache
  • react-native 运行-ios

我现在明白为什么没人能回答这个问题了....

我不得不注释掉我应用程序中的几乎所有代码...一段一段地注释掉,直到错误不再发生。 顽皮的代码行是 import {GiftedChat, Bubble} from 'react-native-gifted-chat'

我的升级版 RN 和 RNGiftedChat 之间似乎存在某种冲突

"react-native": "0.63.3",
"react-native-gifted-chat": "^0.16.3",

可以通过以下任一方式“修复”错误:

  1. 降级RN 或
  2. Remove/replace react-native-gifted-chat.
    .....但是我也不想这样做。

...不太确定从这里去哪里