2021年5月7日星期五

React Native "Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)"

I have already tried "react-native start --reset-cache", "npm start -- --reset-cache", and "npm run android --reset-cache" after closing metro/emulator, which seem to be the suggestions from similar posts. I have also tried "cd android -> gradlew clean -> cd..", and deleting and reinstalling the node_modules folder, neither of which worked for me either. Does anyone have any ideas as to what could be causing this/how to fix it? If any more code snippets are needed let me know. I've spent way too long on this already, I feel like I'm losing my mind. PLEASE help, anything is appreciated

This is the full console output from metro when I do "npm run android"

 BUNDLE  ./index.js     WARN  Require cycle: src\component\FeedList.js -> src\component\FeedCell.js -> src\component\TagDetail.js -> src\component\FeedList.js    Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.   ERROR  ReferenceError: Can't find variable: i   ERROR  Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.        This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.   ERROR  Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.        This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.  

When I reload the app, I get the same error but there are 4 of the same invariant violations instead of 2.

Below are the codes for my files

index.js

import React, { Component } from 'react';  import { Provider } from 'react-redux';  import { AppRegistry} from 'react-native';  import { createStackNavigator} from "react-navigation-stack";  //import { StackNavigator } from 'react-navigation';  import { createAppContainer } from 'react-navigation';  import App from './src/App';  import configureStore from './src/store/index';  import TagDetail from './src/component/TagDetail';  import FeedDetail from './src/component/FeedDetail';  import UserDetail from './src/component/UserDetail';  import SettingsPage from './src/SettingsPage';  import About from './src/About';      import {name as appName} from './app.json';    const store = configureStore();      const AppNavigator = createStackNavigator({    Home: {      screen: App    },    TagDetail: {      screen: TagDetail    },    FeedDetail: {      screen: FeedDetail    },    UserDetail: {      screen: UserDetail    },    SettingsPage: {      screen: SettingsPage    },    AboutPage: {      screen:About    }  },{    headerMode: 'none'  });      export default class Root extends Component {    render() {      return (        <Provider store={store}>          <Apps/>        </Provider>      )    }  }      AppRegistry.registerComponent(appName, () => Root);    const Apps = createAppContainer(AppNavigator);  //export default Apps;    

package.json

{    "name": "TestApp",    "version": "0.0.1",    "private": true,    "scripts": {      "android": "react-native run-android",      "ios": "react-native run-ios",      "start": "react-native start",      "test": "jest",      "lint": "eslint ."    },    "dependencies": {      "@react-native-community/async-storage": "^1.11.0",      "@react-native-community/masked-view": "^0.1.10",      "@react-native-community/viewpager": "^4.0.0",      "aws-sdk": "^2.693.0",      "lodash": "^4.17.15",      "lodash.debounce": "^4.0.8",      "react": "16.13.1",      "react-native": "^0.64.1",      "react-native-deprecated-custom-components": "^0.0.0",      "react-native-gesture-handler": "^1.10.0",      "react-native-image-crop-picker": "^0.31.1",      "react-native-image-picker": "^2.3.1",      "react-native-keyboard-spacer": "^0.4.1",      "react-native-material-menu": "^1.2.0",      "react-native-navbar": "^2.1.0",      "react-native-parallax-scroll-view": "^0.21.3",      "react-native-photo-view": "^1.5.2",      "react-native-safe-area-context": "^3.0.2",      "react-native-screens": "^2.8.0",      "react-native-scrollable-tab-view": "^1.0.0",      "react-native-swiper": "^1.6.0-rc.1",      "react-native-tab-navigator": "^0.3.4",      "react-native-text-ticker": "^1.5.0",      "react-native-vector-icons": "^8.1.0",      "react-native-vertical-view-pager": "^0.1.1",      "react-native-video": "^4.4.5",      "react-native-view-pager": "^0.2.3",      "react-navigation": "^4.3.9",      "react-navigation-stack": "^2.6.0",      "react-redux": "^5.0.6",      "redux": "^3.7.2",      "redux-thunk": "^2.2.0",      "styled-components": "^5.1.1"    },    "devDependencies": {      "@babel/core": "^7.10.2",      "@babel/runtime": "^7.10.2",      "@react-native-community/eslint-config": "^1.1.0",      "babel-jest": "^26.0.1",      "eslint": "^7.2.0",      "jest": "^26.0.1",      "metro-react-native-babel-preset": "^0.59.0",      "react-test-renderer": "16.13.1"    },    "jest": {      "preset": "react-native"    }  }    

app.json

{    "name": "TestApp",    "displayName": "TestApp"  }  
https://stackoverflow.com/questions/67443639/react-native-invariant-violation-module-appregistry-is-not-a-registered-callab May 08, 2021 at 10:51AM

没有评论:

发表评论