I have recently started to convert my react native app and running on Expo so i could test this on my actual android device. I am getting this error above. I have since then running my app using the Expo XDE. I am also running on a windows machine.
The full error message is:
]1
I figured that this has something to do with my index.js, yet here it is
import { AppRegistry } from 'react-native';
import App from './App';
AppRegistry.registerComponent('projectTARA', () => 'App');
Invariant Violation: "main" has not been registered. This can happen if: * Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project. * A module failed to load due to an error and `AppRegistry.
AppRegistry is the JS entry point to running all React Native apps. App root components should register themselves with AppRegistry. registerComponent , then the native system can load the bundle for the app and then actually run the app when it's ready by invoking AppRegistry. runApplication .
js file in the root of your React Native project. index. js is the starting point for React Native applications, and it is always required. It can be a small file that require s other file that are part of your React Native component or application, or it can contain all the code that is needed for it.
The following solution worked:
AppRegistry.registerComponent('main',() => App);
Credits: Rishav Kumar
(Cannot you people just reply to mark as solve ?)
I came across this issue because I had previously run a React project that was not fully shut down. To fix this, I could have restarted my computer. But I chose to do this instead: (Using MacOS, should work with Linux as well, for Windows you would likely need to use Task Manager or similar):
After killing the process you should be able to run your react-native project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With