Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.7k views
in Technique[技术] by (71.8m points)

ios - Module AppRegistry is not a registered callable module

I'm starting with React Native development and I encountered an issue in the very beginning. When trying to run my app I get errors:

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)

My 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)

Other files are simple Component subclasses.

The issue manifests regardless if I run the app from Visual Studio Code or from terminal with react-native run-ios

I looked through existing answers and I didn't find anything that could point me in the right direction:
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

I'm stuck and I don't know where to go from here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

run either npm cache verify or cd ios && pod install and then npm run ios


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...