首页 > 解决方案 > React Native - 不变违规:模块 AppRegistry 不是注册的可调用模块(调用 runApplication)

问题描述

从昨天开始,我已经开始收到此错误Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication),我的应用程序正在工作,但它突然坏了。

谷歌几个小时他们中的大多数人要求 - 删除您的 yarn.lock/package-json.lock 文件并运行 yarn/npm install。然后尝试使用 npx react-native start --reset-cache 清除缓存,但没有一个有效。

尝试删除重新构建应用程序,但失败并出现相同的错误。

我的 - index.js

/**

import App from './App';
import {name as appName} from './app.json';

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

反应原生版本

"react": "16.13.1",
"react-native": "0.63.2",

我所有的依赖项是

包.json

"dependencies": {
    "@ptomasroos/react-native-multi-slider": "^2.2.2",
    "@react-native-community/datetimepicker": "^2.6.0",
    "@react-native-community/masked-view": "^0.1.10",
    "@react-native-community/picker": "^1.6.5",
    "@react-native-community/slider": "^3.0.3",
    "@react-navigation/bottom-tabs": "^5.7.2",
    "@react-navigation/material-top-tabs": "^5.2.14",
    "@react-navigation/native": "^5.7.2",
    "@react-navigation/stack": "^5.8.0",
    "@types/react-native-svg-charts": "^5.0.3",
    "@types/react-redux": "^7.1.9",
    "lottie-ios": "3.1.8",
    "lottie-react-native": "^3.5.0",
    "moment": "^2.27.0",
    "react": "16.13.1",
    "react-moment": "^0.9.7",
    "react-native": "0.63.2",
    "react-native-gesture-handler": "^1.7.0",
    "react-native-reanimated": "^1.10.1",
    "react-native-safe-area-context": "^3.1.1",
    "react-native-screens": "^2.9.0",
    "react-native-svg": "^12.1.0",
    "react-native-svg-charts": "^5.4.0",
    "react-native-swipe-list-view": "^3.2.3",
    "react-native-swiper": "^1.6.0",
    "react-native-tab-view": "^2.15.0",
    "react-redux": "^7.2.1",
    "redux": "^4.0.5"
  }

标签: typescriptreact-native

解决方案


它发生在我身上,当我使用时:

   import { createStackNavigator } from 'react-navigation-stack'

通过将其替换为以下内容解决了该问题:

  import { createStackNavigator } from "@react-navigation/stack";

推荐阅读