There are many other posts with this same title, but most of them are outdated and the answers haven't worked for me. These are some of the fixes I've tried that have failed:
- "react-native start --reset-cache"
- "npm start -- --reset-cache"
- "npm run android --reset-cache"
- "cd android -> gradlew clean -> cd.."
- deleting and reinstalling the node_modules folder
- deleting and reinstalling node_modules folder before and after updating react-native and doing /npm audit fix. It says there's 0 vulnerabilities
- yarn install and yarn upgrade
This problem happens when I try to run it, even after restarting my computer. I use npm run android to start the app. I noticed that around the time this stopped working, I accidentally added some typescript files to the project without any additional packages. I have since removed them, but is it possible that's what's causing it? I don't believe its a problem with the entry file path as the error states for the reason mentioned below.
Does anyone have any other ideas how to fix it? If any more code snippets are needed let me know. Any further questions or advice that could lead the way is appreciated
My getJSMainModuleName() returns "index" which should be correct, as thats worked in the past on this project, which makes me believe it may not be the entry file path thats incorrect like the error says it could be.
This is the full console output from metro when I do "npm run android". I don't think the cycle or the referenceerror are causing the invariant violation.
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. (noting this incase its relevant)
Below are selected files from my project
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"
}