我正在做一个React Native项目,最初是使用React Native CLI创建的。其他团队成员在我加入之前就已经开始工作了,所以我现在基本上是在为这个项目做贡献。我需要在物理设备上预览应用程序,因为我使用的是Windows,只有一个iOS设备,所以我安装了Expo。我可以运行npx expo start
并扫描QR码。这会启动Expo Go应用程序,但显示4个错误(和1个警告)。
其中一个错误说我的"JavaScript code tried to access a native module that doesn't exist"
,但没有确切地指出有问题的模块,这使得很难找出问题是什么。
我试着在谷歌上搜索错误,但似乎没有什么相关信息。我找到了这个question,但它实际上无助于查明导致问题的确切模块。我还发现读取Expo doc时无法添加自定义本机代码。TypeScript代码是否可能包含Expo不支持的模块?
另一个错误似乎来自不匹配的类型("undefined不是对象"),但我还是无法理解它。
这次我使用Expo CLI从头开始创建了一个项目,只复制了源文件,排除了android
和ios
文件夹,以确保它们是从头重建的,运行yarn install
重新创建package.json,但错误仍然存在。所以错误肯定是在TypeScript代码中,但我没有足够的知识来找到它。
错误(按其在日志控制台中的显示顺序):
(一)
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)
1条答案
按热度按时间oxalkeyp1#
打开名为= screens的文件,然后查看它是否有函数= OnboardingScreen,查看它调用了哪些lib和/或其他函数。