我从 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 verify
或 cd ios && pod install
然后 npm run ios
关于ios - 模块 AppRegistry 不是注册的可调用模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59752968/