react-native: ERROR Invariant Violation: Module AppRegistry is not a registered callable module ( React native V6)
Description
ERROR TypeError: undefined is not an object (evaluating ‘Object.keys(o)’) 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.
Version
0.67
Output of npx react-native info
BUNDLE ./index.js
ERROR TypeError: undefined is not an object (evaluating ‘Object.keys(o)’) 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. [Info] Stopping Packager
Steps to reproduce
Whenever i am adding StackNavigator code in my App.js then showing above issue… I tried all possible solution to resolve it. but it’s showing same bug again and again.
Snack, code example, screenshot, or link to a repository
App.js `import {NavigationContainer} from ‘@react-navigation/native’; import React from ‘react’; import ‘react-native-gesture-handler’; import {createStackNavigator} from ‘react-navigation-stack’; import Home from ‘./Home’;
const Stack = createStackNavigator(); const SectionListBasics = () => { return ( <> <NavigationContainer> <Stack.Navigator initialRouteName=“Home” headerMode=“Screen”> <Stack.Screen name=“Home” options={{ headerShown: false, }}> {props => <Home {…props} username=“Sports Fan” />} </Stack.Screen> </Stack.Navigator> </NavigationContainer> </> ); };
export default SectionListBasics; `
package.json
{ "name": "AwesomeProject", "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/masked-view": "^0.1.11", "@react-navigation/bottom-tabs": "^6.0.9", "@react-navigation/drawer": "^6.1.8", "@react-navigation/native": "^6.0.6", "react": "17.0.2", "react-native": "0.67.1", "react-native-gesture-handler": "^2.2.0", "react-native-reanimated": "^2.2.4", "react-native-safe-area-context": "^3.3.2", "react-native-screens": "^3.10.2", "react-native-vector-icons": "^9.0.0", "react-navigation-stack": "^2.10.4" }, "devDependencies": { "@babel/core": "7.16.10", "@babel/runtime": "7.16.7", "@react-native-community/eslint-config": "2.0.0", "babel-jest": "26.6.3", "eslint": "7.14.0", "jest": "26.6.3", "metro-react-native-babel-preset": "0.66.2", "react-test-renderer": "17.0.2" }, "jest": { "preset": "react-native" } }
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 5
- Comments: 48
Commits related to this issue
- fix : err fix by default setting https://github.com/facebook/react-native/issues/32952 — committed to EFUB-ZEJE/ZEJE-FrontEnd by flowersayo 2 years ago
This issue is mostly happen when
node_modules
folder has been changed by installing new library or some sort of action. Please try removing cache and doyarn install
ornpm install
againTry to add this line in the file where you add the navigation:
this has worked for me.
This worked for me:
This worked for me thx 😃)
@Xplosive06 After having done that I have a problem because a lot of files were updated, do you had this problem?
@autonauta @arrluubuutee Have you added
metro.config.js
file in your project? I was having the same problem, and what worked for me was I added this file with the code:also, add this in your
babel.config.js
fileKeep your
devDependencies
inpackage.json
like thisUn-installing the app and re-building it using
npx react-native run-android
did the job for me.simple solution that worked for me, make sure your project is clean. if your project is clean and it didn’t work? have a glass of water and “relax”…visit each folder, remove unnecessary libraries that you have added or imports* in each screen (only have what your using*) also use import * as React from ‘react’;
I was having the issue, but resolved after discarding the changes. dropping back to
"react-native": "0.64.2"
same issue here
I’m also having the same problem in version 0.68.2 without using hermes. When I run react-native packager, I got the follow error messages.
Output of
npx react-native info
Thanks Finally this methods worked for me
I’m having the same error:
for Android it works, but for IOS it gives this error
My package.json:
In my case the problem was the following. After refactoring and removing some of my styles files I forgot to remove the calling of removed file:
I received the same error that is described here, but before it I had a message related to that:
So my idea is to check any errors that come before the Invariant Violation error message and try to fix them. In my case I even tried to clear all the cache and build but it didn’t help. Then I noticed that I have a reference error. >.< After removing calling to the missing file invariant error disappeared.
Error: Reanimated 2 failed to create a worklet, maybe you forgot to add Reanimated’s babel plugin? 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.
The issue persists I got this issue when I tried using the library known as @react-native-voice/voice Below are the dependencies Below is the output of the error
I have been solved issue(https://github.com/facebook/react-native/issues/32952#issuecomment-1175782321) by exported
ViewPropTypes
fromdeprecated-react-native-prop-types
in some packages like below.The problem is some of node dependencies are export
ViewPropTypes
fromreact-native
, not exportdeprecated-react-native-prop-types
.react-native-snap-carousel
react-native-dash
Im having the same problem, tried react-native-cleanproject and cache reset but nothing
I faced a comparable challenge, pinpointing it to an issue stemming from react-native-reanimated. For detailed troubleshooting guidance, check out:https://docs.swmansion.com/react-native-reanimated/docs/guides/troubleshooting/#failed-to-create-a-worklet
I would ask my self wtf do I need to re-install again if the error is in code, I would say this should have better resolution then re-installing all packages again
Add a few lines in MainApplication.java from this file https://github.com/software-mansion-labs/reanimated-2-playground/blob/master/android/app/src/main/java/com/reanimated2playground/MainApplication.java
Any cache cleaning, reanimated babel plugin setup advices did not help.
Add this imports.
import com.facebook.react.bridge.JSIModulePackage;
import com.swmansion.reanimated.ReanimatedJSIModulePackage;
Also add this method in ReactNativeHostWrapper
protected JSIModulePackage getJSIModulePackage() { return new ReanimatedJSIModulePackage(); }
And finally delete package-lock.json, reinstall node_modules, clean npm/yarn cache.
I have changed the name of the main folder now receiving this error in ios. can not resolve this problem… any help?
I’m facing this on expo-go (IOS ) but running on android 😦