React Native 我得到TypeError:更新Expo SDK时,undefined不是对象(正在评估“nativeModule.__expo_module_name__”)

gijlo24d  于 2023-10-22  发布在  React
关注(0)|答案(1)|浏览(127)

我用的是Expo 45版本,现在已经没有了。由于这个原因,我试图升级,但当我运行升级后的应用程序,我得到以下错误。

ERROR  TypeError: Cannot read property '__expo_module_name__' of undefined, 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

我读了下面的文章,但还是找不到解决办法。https://docs.expo.dev/troubleshooting/application-has-not-been-registered/
yarn why react-native-safe-area-context的输出如下。

yarn why v1.22.19
[1/4] 🤔  Why do we have the module "react-native-safe-area-context"...?
[2/4] 🚚  Initialising dependency graph...
[3/4] 🔍  Finding dependency...
[4/4] 🚡  Calculating file sizes...
=> Found "react-native-safe-[email protected]"
info Has been hoisted to "react-native-safe-area-context"
info This module exists because it's specified in "dependencies".
info Disk size without dependencies: "1004KB"
info Disk size with unique dependencies: "1004KB"
info Disk size with transitive dependencies: "1004KB"
info Number of shared dependencies: 0
✨  Done in 0.22s.

有人知道如何解决这个错误吗?
编辑:
我找到了导致问题的部分。expo-ads-admob软件包导致此错误。当我打开包裹时,问题就消失了。但我找不到确切的原因是这个包导致这个错误。我继续研究。
编辑2:
https://blog.expo.dev/adding-admob-to-your-expo-project-aa4e48ac848
这篇文章的更新说明说,这个软件包已经停止。我认为错误是由版本不匹配引起的。

ryoqjall

ryoqjall1#

我有这个相同的错误在目前和它开始时,我安装了安装位置。
编辑:我后来意识到这是因为我以下面的形式导入了位置==> import * as Location from "expo-location"

相关问题