expo / router

[ARCHIVE]: Expo Router has moved to expo/expo -- The File-based router for universal React Native apps
https://docs.expo.dev/routing/introduction/
1.37k stars 114 forks source link

ERROR Error: Cannot find native module 'ExpoHead', js engine: hermes #525

Closed alyiev closed 1 year ago

alyiev commented 1 year ago

Which package manager are you using? (Yarn is recommended)

yarn

Summary

ERROR Error: Cannot find native module 'ExpoHead', js engine: hermes ERROR Invariant Violation: "main" has not been registered. This can happen if:

Minimal reproducible example

using yarn 3.5+

image

index.tsx:

import { View } from 'react-native';
import { Link, Stack } from 'expo-router';

// import PlaceList from '../src/components/Delivery/PlaceLIst';
// import { restaurants } from '../src/data';

const MainScreen = () => {
  return (
    <Stack.Screen
      options={{
        animation: 'fade',
        headerShown: false,
      }}
    />
  );
};

export default MainScreen;

_layout.tsx:

import { Text } from 'react-native';
import { SplashScreen } from 'expo-router';

import {
  useFonts,
  Andika_400Regular as andika400r,
  Andika_700Bold as andika700b,
} from '@expo-google-fonts/andika';

const Layout = () => {
  const [fontsLoaded] = useFonts({
    andika400r,
    andika700b,
  });

  if (!fontsLoaded) {
    return <SplashScreen />;
  }

  return <Text>123</Text>;
};

export default Layout;
alyiev commented 1 year ago

Did https://expo.github.io/router/docs/troubleshooting/#expo_router_app_root-not-defined

and now getting this:

 ERROR  Warning: React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

Check the render method of `GestureHandler`.
    in GestureHandler (created by ExpoRoot)
    in ExpoRoot (created by App)
    in App (created by withDevTools(App))
    in withDevTools(App)
    in RCTView (created by View)
    in View (created by AppContainer)
    in RCTView (created by View)
    in View (created by AppContainer)
    in AppContainer
    in main(RootComponent)
alyiev commented 1 year ago

Reverted to 1.4.3 and it works fine.

What is the problem here in the new version?

EvanBacon commented 1 year ago

The @next version of expo-router (used for v2) has a new native module on iOS that requires a native rebuild. In Expo Go, Android, and web this is not an issue. To fix, simply npx expo run:ios or eas build.

alyiev commented 1 year ago

@EvanBacon doesn't help, getting the same issue

budzHors7 commented 1 year ago

Just Updated my project from Expo 48 to ^49.0.0, Today.

When I run my project on Expo Go, I get this error:

Error: Cannot find native module 'ExpoDevMenu', js engine: hermes

And, Yes I'm using Expo Router.

shanoysinc commented 1 year ago

Just Updated my project from Expo 48 to ^49.0.0, Today.

When I run my project on Expo Go, I get this error:

Error: Cannot find native module 'ExpoDevMenu', js engine: hermes

And, Yes I'm using Expo Router.

same here but am not using expo router

mb8z commented 1 year ago

@EvanBacon Encountering the same issue. Previously I had an index.js file in the root directory:

import { registerRootComponent } from 'expo';

import App from './App';

// registerRootComponent calls AppRegistry.registerComponent('main', () => App);
// It also ensures that whether you load the app in Expo Go or in a native build,
// the environment is set up appropriately
registerRootComponent(App);

The referenced above ./App was a App.tsx also placed in the root directory:

import 'expo-dev-client';
import Root from './src';

export default Root;

And then the Root was basically the whole app.

Now – do I understand it correctly – I don't need any of these as the main in package.json became expo-router/entry?

I'm using expo@49.0.6 with expo-router@2.0.0. I've removed pakcage-json.lock, node_modules, ios, and did npx expo run:ios What I get is:

 ERROR  Error: Cannot find native module 'ExpoHead', js engine: hermes
 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., js engine: hermes

Edit No idea why the answers come always after writting an issue or a SO post, but – I was migrating to expo-router@2.0.0 from @react-native/navigation and I had an app built with previous setup. Doing clean install (removing package-lock.json file, node_modules &ios directories, then npm install, then launching the simulator and removing the previously visible app, and then doing npx expo run:ios helped.

VivekNeel commented 1 year ago

Make sure you are not using development build. use expo go

Jhon-Idrovo commented 8 months ago

Make sure you are not using development build. use expo go

You might say "make sure you're not using expo" as well

perhapsubhan commented 5 months ago

I'm having the same error: ERROR Error: Cannot find native module 'ExponentAV', js engine: hermes. I'm using dev build of expo with expo cli. What should I do?

LMarcinkowski commented 5 months ago

I'm having the same error: ERROR Error: Cannot find native module 'ExponentAV', js engine: hermes. I'm using dev build of expo with expo cli. What should I do?

Same here...

Emmanueldmlr commented 4 months ago

Same here

I'm having the same error: ERROR Error: Cannot find native module 'ExponentAV', js engine: hermes. I'm using dev build of expo with expo cli. What should I do?

fimbres commented 4 months ago

Same, any update?

Acrylic125 commented 4 months ago

Running into a similar issue,

ERROR Error: Cannot find native module 'ExponentAV', js engine: hermes

After experimenting a bit more, it seems to be happening on my EAS install for dev mode (Have no tried prod). However, on the simulator and Expo Go, it seems to be fine.

EDIT: An update, I managed to resolve my issue. As it turns out, I had to rebuild my EAS dev build. Might be related, but when running expo-doctor, it warned me about the following:

Check for common project setup issues

Upon further inspection, it turns out I was committing my ios and android folder so I had to remove that, and add both folders to my .gitignore.

Then I rebuilt my EAS dev build, reinstalled the whole app from scratch again, then booted my dev server using npm run ios and it no longer yells at me about this issue.

EClinick commented 2 months ago

Same, any update?

Same, Any update? Been trying to debug for the past 2 weeks

jonoise commented 2 weeks ago

What worked for me was to run npx expo run:ios. In my case i'm mainly developing for iOS. Also make sure your routes are set up correctly. Fix your with an href pointing to a non existing route.