我使用的是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-area-context@4.5.0"
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
这篇文章的更新说明说这个包已经停产了。我认为这个错误是由版本不匹配引起的。
我现在有同样的错误,它开始时,我安装了expo-location
编辑:我后来意识到这是因为我以以下形式导入了位置==>import * as Location from "expo-location"