开发者问题收集

React Native Location 正在评估'nativeModule.__expo_module_name__'

2023-01-29
641

我已经安装了 expo Location:

npx expo install expo-location

每当我尝试在我的应用程序中使用它时都会出现错误

import * as Location from 'expo-location';
console.log(Location) //Leads to an Error when I try to call it

错误:

Android Bundling complete 3254ms
 ERROR  TypeError: undefined is not an object (evaluating 'nativeModule.__expo_module_name__')
 ERROR  Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). Module has not been registered as callable. Registered callable JavaScript modules (n = 11): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, JSDevSupportModule, HMRClient, RCTEventEmitter.
        A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.
 ERROR  Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). Module has not been registered as callable. Registered callable JavaScript modules (n = 11): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, JSDevSupportModule, HMRClient, RCTEventEmitter.
        A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.

Package.Json 中的依赖项:

"dependencies": {
    **"expo": "~47.0.9",**
    "expo-file-system": "~15.1.1",
    **"expo-location": "~15.0.1",**
    "expo-updates": "^0.15.6",
    "react": "18.1.0",
    "react-native": "0.70.5",
    "react-native-maps": "^1.3.2",
}
2个回答

我通过使用 eas 重新构建修复了此错误

eas build --profile development --platform android
Mahmoud Hlal
2023-01-31

我发现错误发生的原因是在 package.json 文件中,请求的模块仅列在 devDependencies 下,而不是依赖项下。我将其复制到依赖项,问题已解决。 在此处输入图片描述

Mikel Cabezas
2023-08-27