I am working on a React Native project that was roginally crated using the React Native CLI. The other team members had started working before I joined, so I'm essentially contributing to the project now.I need to preview the app on a physical device, and since I'm using Windows and only have an iOS device, I installed Expo. I am able to run npx expo start
and scan the QR code, which launches the Expo Go app, but shows 4 errors (and 1 warning).
One of the error says that my "JavaScript code tried to access a native module that doesn't exist"
but doesn't point exactly the module(s) in question, which makes it really hard to find out what the issue is.
I tried googling the error but there seems to be little info about it. I found this question but it doesn't really help in pinpointing the exact module(s) causing the issue.I could also find reading the Expo doc that I cannot add custom native code. Is it possible that the TypeScript code includes a module that isn't supported by Expo?
Another error seems to come from mismatch types ("undefined is not an object"), but yet again, I am unable to understand it.
I ended up creating a project from scratch using the Expo CLI this time, and copying only the source files, excluding the android
and ios
folders to make sure they're rebuilt from scratch, running yarn install
to recreate the package.json, but the error still persists. So the error definitely is in the TypeScript code, but I do not have enough knowledge to find it out.
The errors, in the order in which they appears in the log console:
1)
TypeError: undefined is not an object (evaluating '_$$_REQUIRE(_dependencyMap[7], "../features/auth/screens").OnboardingScreen')This error is located at: in AppStackNavigator (at App.tsx:25) in AuthContextProvider (at App.tsx:24) in EnsureSingleNavigator (at BaseNavigationContainer.tsx:430) in BaseNavigationContainer (at NavigationContainer.tsx:132) in ThemeProvider (at NavigationContainer.tsx:131) in NavigationContainerInner (at App.tsx:23) in RCTView (at View.js:32) in View (at GestureHandlerRootView.tsx:17) in GestureHandlerRootView (at App.tsx:22) in App (created by ExpoRoot) in ExpoRoot (at renderApplication.js:50) in RCTView (at View.js:32) in View (at AppContainer.js:92) in DevAppContainer (at AppContainer.js:107) in RCTView (at View.js:32) in View (at AppContainer.js:119) in AppContainer (at renderApplication.js:43) in main(RootComponent) (at renderApplication.js:60)
Invariant Violation: Your JavaScript code tried to access a native module that doesn't exist.If you're trying to use a module that is not supported in Expo Go, you need to create a development build of your app. See https://docs.expo.dev/development/introduction/ for more info
Error: Your JavaScript code tried to access a native module that doesn't exist.If you're trying to use a module that is not supported in Expo Go, you need to create a development build of your app. See https://docs.expo.dev/development/introduction/ for more info.
TypeError: undefined is not an object (evaluating '_$$_REQUIRE(_dependencyMap[7], "../features/auth/screens").OnboardingScreen')This error is located at: in AppStackNavigator (at App.tsx:25) in AuthContextProvider (at App.tsx:24) in EnsureSingleNavigator (at BaseNavigationContainer.tsx:430) in BaseNavigationContainer (at NavigationContainer.tsx:132) in ThemeProvider (at NavigationContainer.tsx:131) in NavigationContainerInner (at App.tsx:23) in RCTView (at View.js:32) in View (at GestureHandlerRootView.tsx:17) in GestureHandlerRootView (at App.tsx:22) in App (created by ExpoRoot) in ExpoRoot (at renderApplication.js:50) in RCTView (at View.js:32) in View (at AppContainer.js:92) in DevAppContainer (at AppContainer.js:107) in RCTView (at View.js:32) in View (at AppContainer.js:119) in AppContainer (at renderApplication.js:43) in main(RootComponent) (at renderApplication.js:60)