expo: Error: Cannot find native module 'ExpoApplication', js engine: hermes

Minimal reproducible example

@clerk/clerk-expo”: “^0.20.2” Expo SDK 50 dev build error


import FontAwesome from "@expo/vector-icons/FontAwesome";
import {
  DarkTheme,
  DefaultTheme,
  ThemeProvider,
} from "@react-navigation/native";
import { useFonts } from "expo-font";
import { Stack } from "expo-router";
import * as SplashScreen from "expo-splash-screen";
import { useEffect } from "react";
import { ClerkProvider } from "@clerk/clerk-expo";

import { useColorScheme } from "@/components/useColorScheme";

export {
  // Catch any errors thrown by the Layout component.
  ErrorBoundary,
} from "expo-router";

export const unstable_settings = {
  // Ensure that reloading on `/modal` keeps a back button present.
  initialRouteName: "(tabs)",
};

// Prevent the splash screen from auto-hiding before asset loading is complete.
SplashScreen.preventAutoHideAsync();

export default function RootLayout() {
  const [loaded, error] = useFonts({
    SpaceMono: require("../../assets/fonts/SpaceMono-Regular.ttf"),
    ...FontAwesome.font,
  });

  // Expo Router uses Error Boundaries to catch errors in the navigation tree.
  useEffect(() => {
    if (error) throw error;
  }, [error]);

  useEffect(() => {
    if (loaded) {
      SplashScreen.hideAsync();
    }
  }, [loaded]);

  if (!loaded) {
    return null;
  }

//place 'pk_test_' it with ur clerk public key 

  return (
    <ClerkProvider publishableKey="pk_test_">
      <RootLayoutNav />
    </ClerkProvider>
  );
}

function RootLayoutNav() {
  const colorScheme = useColorScheme();

  return (
    <ThemeProvider value={colorScheme === "dark" ? DarkTheme : DefaultTheme}>
      <Stack>
        <Stack.Screen name="(tabs)" options={{ headerShown: false }} />
        <Stack.Screen name="modal" options={{ presentation: "modal" }} />
      </Stack>
    </ThemeProvider>
  );
}


Summary

{
  "name": "testApp",
  "main": "expo-router/entry",
  "version": "1.0.0",
  "scripts": {
    "start": "expo start",
    "android": "expo run:android",
    "ios": "expo run:ios",
    "web": "expo start --web",
    "test": "jest --watchAll"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "@clerk/clerk-expo": "^0.20.2",
    "@expo/vector-icons": "^14.0.0",
    "@react-navigation/native": "^6.0.2",
    "expo": "~50.0.5",
    "expo-font": "~11.10.2",
    "expo-linking": "~6.2.2",
    "expo-router": "~3.4.6",
    "expo-splash-screen": "~0.26.4",
    "expo-status-bar": "~1.11.1",
    "expo-system-ui": "~2.9.3",
    "expo-web-browser": "~12.8.2",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-native": "0.73.2",
    "react-native-safe-area-context": "4.8.2",
    "react-native-screens": "~3.29.0",
    "react-native-web": "~0.19.6"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@types/react": "~18.2.45",
    "jest": "^29.2.1",
    "jest-expo": "~50.0.1",
    "react-test-renderer": "18.2.0",
    "typescript": "^5.1.3"
  },
  "private": true
}

Error :

Error: Cannot find native module 'ExpoApplication', js engine: hermes
    at ContextNavigator (http://localhost:8081/node_modules/expo-router/entry.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=co.za.bibleai.testapp&transform.routerRoot=src%2Fapp&transform.engine=hermes:152352:24)
    at ExpoRoot (http://localhost:8081/node_modules/expo-router/entry.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=co.za.bibleai.testapp&transform.routerRoot=src%2Fapp&transform.engine=hermes:152308:28)
    at App
    at ErrorToastContainer (http://localhost:8081/node_modules/expo-router/entry.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=co.za.bibleai.testapp&transform.routerRoot=src%2Fapp&transform.engine=hermes:162446:24)
    at ErrorOverlay
    at withDevTools(ErrorOverlay) (http://localhost:8081/node_modules/expo-router/entry.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=co.za.bibleai.testapp&transform.routerRoot=src%2Fapp&transform.engine=hermes:161980:27)
    at RCTView
    at View (http://localhost:8081/node_modules/expo-router/entry.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=co.za.bibleai.testapp&transform.routerRoot=src%2Fapp&transform.engine=hermes:40740:43)
    at RCTView
    at View (http://localhost:8081/node_modules/expo-router/entry.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=co.za.bibleai.testapp&transform.routerRoot=src%2Fapp&transform.engine=hermes:40740:43)
    at AppContainer (http://localhost:8081/node_modules/expo-router/entry.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=co.za.bibleai.testapp&transform.routerRoot=src%2Fapp&transform.engine=hermes:40551:36)
    at main(RootComponent) (http://localhost:8081/node_modules/expo-router/entry.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=co.za.bibleai.testapp&transform.routerRoot=src%2Fapp&transform.engine=hermes:124397:28)

Environment

expo-env-info 1.2.0 environment info: System: OS: macOS 14.1.1 Shell: 5.9 - /bin/zsh Binaries: Node: 18.18.2 - ~/.nvm/versions/node/v18.18.2/bin/node npm: 9.8.1 - ~/.nvm/versions/node/v18.18.2/bin/npm Watchman: 2023.11.27.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.14.3 - /Users/aris/.rbenv/shims/pod SDKs: iOS SDK: Platforms: DriverKit 23.2, iOS 17.2, macOS 14.2, tvOS 17.2, visionOS 1.0, watchOS 10.2 IDEs: Xcode: 15.2/15C500b - /usr/bin/xcodebuild npmPackages: expo: ~50.0.5 => 50.0.5 expo-router: ~3.4.6 => 3.4.6 react: 18.2.0 => 18.2.0 react-dom: 18.2.0 => 18.2.0 react-native: 0.73.2 => 0.73.2 react-native-web: ~0.19.6 => 0.19.10 npmGlobalPackages: eas-cli: 7.0.0 Expo Workflow: bare

About this issue

  • Original URL
  • State: closed
  • Created 5 months ago
  • Comments: 15

Most upvoted comments

TL;DR try installing the missing package in your app or if you have a monorepo expo workspace. In my case using pnpm in a monorepo I run the following from the root folder pnpm expo install expo-application -- --filter expo and did the same with any other missing packages expo-web-browser and expo-auth-session


I’ve been dealing with this issue for the last few days and I think I finally managed to get this working. Unfortunately I cannot say I do understand 100% what’s going on but I’ll try to summarize my findings below.

The original app I’ve been working with was bootstrapped with Create T3 Turbo, using pnpm as package manager and I subsequently added Clerk for authentications. Everything worked fine on Expo-Go but when building locally I got Cannot find native module 'ExpoApplication' and Cannot find native module 'ExpoWebBrowser'.

My app also had lot of other packages added on top of if so I decided to restart from a clean instance of create-t3-turbo and I can see expo-go, local builds and EAS builds work fine until I added Clerk to the mix.

One of the thing I tried is switching package manager as I think the expo doc reference yarn when it comes to monorepos… By doing so I got errors even within expo-go about the following 3 packages missing expo-application, expo-web-browser and expo-auth-session. I installed these with expo install within my expo workspace and things now works both in expo-go and when I do a local build or a EAS build.

Those 3 packages seems to be dependencies for Clerk and If I look at the pnpm lockfile I can see the following:

  /@clerk/clerk-expo@0.20.10(@types/react@18.2.57)(expo-application@5.8.4)(expo-auth-session@5.4.0)(expo-constants@15.4.6)(expo-web-browser@12.8.2)(react-dom@18.2.0)(react-native@0.73.6)(react@18.2.0):
    resolution: {integrity: sha512-RHjIpQPEB8gs0YnPVRCHYzObIyxocsXycRHDQGEP60Rn32pF1lbPvJOfRxU13734w+OXs06cEtsoJLA8H3ECtQ==}
    engines: {node: '>=14'}
    peerDependencies:
      expo-application: '>=5'
      expo-auth-session: '>=4'
      expo-constants: '>=14'
      expo-web-browser: '>=12'
      react: '>=16'

while I couldn’t see the packages anywhere in the yarn lockifle that I guess is the reason they couldn’t be resolved in the first place until i installed them.

I went back to the pnpm version of my app and installed those 3 packages manually in the expo workspace and the local build now works.

I hope this is helpfull.

I don’t think it’s related to the expo-device package itself. I am also facing this issue on a base template out of the box once i set expo-dev-client as the build.

I was also facing this issue but it appears that I just needed to rebuild the app as it was obviously not in sync with the js code. Don’t hesitate to uninstall remove everything from your device about your build and then reinstall.