expo: Invariant Violation: "main" has not been registered.

Just updated expo-cli and initialized a new project with the TypeScript Tabs template. I did not touch the code. Navigated to the project’s directory and ran yarn start and was met with this error:

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.registerComponent’ wasn’t called.

Tried to resolve by using registerRootComponent, but that is not working either.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 8
  • Comments: 23 (7 by maintainers)

Most upvoted comments

I upgraded my projects to sdk 38.0.8. I get the same issue.

having same issue after my upgrade from 37 to 38.0.8

Having the same issue (SDK 38.0.8).

run yarn why react-native-safe-area-context to see if you have multiple versions of the package. i’m not sure what the equivalent is for npm - i think there isn’t one - but you can look in your package-lock.json if you use that.

what you want to do here is verify that there is just a single instance of react-native-safe-area-context in your project. if there is a different version used by the expo package than you are using in your package.json, then change the version in your package.json to match the one from the expo package.

i initialized a new project on sdk-37 with expo init toup --template=blank@sdk-37 then did expo install react-native-safe-area-context then ran expo upgrade and it worked as expected.

if the above is not the issue for your project, it’s possible that there is some other dependency that is causing issues. you can debug further by looking at your logs, or opening chrome debugger. we will need more information on your project to help though, ideally access to the repository or a minimal reproducible example.