React Native Location 评估'nativeModule.__expo_module_name__'

问题描述 投票:0回答:2

我已经安装了expo位置:

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",
}

javascript react-native expo location
2个回答
2
投票

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

eas build --profile development --platform android

0
投票

我发现发生错误是因为在package.json文件中,请求的模块仅列在devDependencies下,而不是dependency下。我将其复制到依赖项中,问题已解决。enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.