ios - 模块 AppRegistry 不是注册的可调用模块

标签 ios react-native

我从 React Native 开发开始,一开始就遇到了一个问题。尝试运行我的应用程序时出现错误:

Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)
Unhandled JS Exception: Invariant Violation: Native module cannot be null.
Unhandled JS Exception: Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)



我的 App.js:
import React, { Component } from 'react';
import { SafeAreaView } from 'react-native';
import DefaultRouter from './src/navigation/DefaultRouter'

export default class App extends Component {
  render() {
    return (
      <SafeAreaView>
        <DefaultRouter />
      </SafeAreaView>
      );
    }
  };

index.js:
import { AppRegistry } from 'react-native';
import App from './App';
import {name as appName} from './app.json';

AppRegistry.registerComponent(appName, () => App);

DefaultRouter.js:
import { createSwitchNavigator, createAppContainer } from 'react-navigation';
import LoginScreen from '../screen/LoginScreen';
import DefaultTabBar from '../navigation/TabBar';

const DefaultRouter = createSwitchNavigator({
    LOGIN_SCREEN: {
        screen: LoginScreen
    },
    TAB_NAVIGATION: {
        screen: DefaultTabBar
    }
}, {
    initialRouteName: 'LOGIN_SCREEN',
    headerMode: 'none'
})

export default createAppContainer(DefaultRouter)

其他文件很简单Component子类。

无论我是从 Visual Studio Code 还是使用 react-native run-ios 的终端运行应用程序,问题都会出现

我查看了现有的答案,但没有找到任何可以为我指明正确方向的东西:
React-Native: Module AppRegistry is not a registered callable module
React Native: Module AppRegistry is not a registered callable module (calling runApplication)
module appregistry is not a registered callable module (calling runApplication)
Module AppRegistry is not a registered callable module and Cant find variable: Constants
React Native Module AppRegistry is not a registered callable module
Module AppRegistry is not a registered callable module only in Release configuration

我被困住了,我不知道从这里去哪里

最佳答案

运行npm cache verifycd ios && pod install然后 npm run ios

关于ios - 模块 AppRegistry 不是注册的可调用模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59752968/

相关文章:

ios - React native - 如何实现 iOS 设置

reactjs - Redux Form 6.1.1 - 模糊验证不适用于 react native

javascript - 我应该将 Firebase 代码添加到哪个 appDelegate 文件中?

javascript - 数组的元素和长度的值未定义(从 Firebase 获取时)

ios - swift 3 : unexpectedly found nil while unwrapping an Optional value

ios - UITableViewCells 初始加载 View /显示问题

iphone - 从设备获取 NSUserDefaults plist 文件

android - 如何在运行 expo build android 时修复此错误?

objective-c - 未检测到已删除的条目-iOS

ios - 点击 addChild viewController 不起作用