加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angular – Ionic 4原生插件地理定位给我“找不到模块:错误:无

发布时间:2020-12-17 07:07:02 所属栏目:安全 来源:网络整理
导读:我试图在离子4中使用离子原生插件地理定位,但我收到了这个错误: Failed to compile. ./node_modules/@ionic-native/geolocation/index.js Module not found: Error: Can’t resolve ‘rxjs/Observable’ in ‘C:Projectsionicprayersnode_modules@ioni
我试图在离子4中使用离子原生插件地理定位,但我收到了这个错误:

Failed to compile.

./node_modules/@ionic-native/geolocation/index.js Module not found:
Error: Can’t resolve ‘rxjs/Observable’ in
‘C:Projectsionicprayersnode_modules@ionic-nativegeolocation’

这是我的依赖:

"dependencies": {
    "@angular/common": "6.0.9","@angular/core": "6.0.9","@angular/forms": "6.0.9","@angular/http": "6.0.9","@angular/platform-browser": "6.0.9","@angular/platform-browser-dynamic": "6.0.9","@angular/router": "6.0.9","@ionic-native/core": "5.0.0-beta.14","@ionic-native/geolocation": "^4.11.0","@ionic-native/splash-screen": "5.0.0-beta.14","@ionic-native/status-bar": "5.0.0-beta.14","@ionic/angular": "4.0.0-beta.0","@ionic/ng-toolkit": "1.0.0","@ionic/schematics-angular": "1.0.1","cordova-plugin-geolocation": "^4.0.1","core-js": "^2.5.3","rxjs": "6.2.2","zone.js": "^0.8.26"
  },

这是我使用的代码: –

app.module.ts

import { Geolocation } from '@ionic-native/geolocation';
...
NgModule({
  declarations: [AppComponent],entryComponents: [],imports: [BrowserModule,IonicModule.forRoot(),AppRoutingModule],providers: [
    StatusBar,SplashScreen,Geolocation,{ provide: RouteReuseStrategy,useClass: IonicRouteStrategy }
  ],bootstrap: [AppComponent]
})

home.ts

import { Geolocation } from '@ionic-native/geolocation';
...
constructor(private geolocation: Geolocation) {}

解决方法

您在更改导入语句的位置安装了rxjs 6.2.2.

稳定的离子天然仍然使用rxjs 5.x.

您可以查看迁移指南here.

你可以使用rxjs-compat

npm i rxjs-compat --save

或者回到5.x版本.

另一种选择是将@ ionic-native / geolocation版本更新为5.0.0-beta14

就像你的其他离子原生插件一样,根据package.json,它应该使用rxjs 6.x

npm i --save @ionic-native/geolocation@5.0.0-beta.14

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读