【问题标题】:Typescript Error Cannot find name 'Observable' in @ionic-native/geolocation打字稿错误在@ionic-native/geolocation 中找不到名称'Observable'
【发布时间】:2017-05-06 18:52:02
【问题描述】:

我正在使用 Ionic 2 并尝试使用 @ionic-native/geolocation,当我在我的项目上执行 ionic:serv 时,我得到了这个错误: 找不到名称“可观察”。

tack.imgur.com/dXNDc.png

这是我的 package.json 文件内容:

{
  "author": "",
  "cordovaPlatforms": [],
  "cordovaPlugins": [
    "cordova-plugin-whitelist",
    "cordova-plugin-console",
    "cordova-plugin-statusbar",
    "cordova-plugin-device",
    "cordova-plugin-splashscreen",
    "ionic-plugin-keyboard",
    "cordova-plugin-geolocation"
  ],
  "dependencies": {
    "@angular/common": "4.0.2",
    "@angular/compiler": "4.0.2",
    "@angular/compiler-cli": "4.0.2",
    "@angular/core": "4.0.2",
    "@angular/forms": "4.0.2",
    "@angular/http": "4.0.2",
    "@angular/platform-browser": "4.0.2",
    "@angular/platform-browser-dynamic": "4.0.2",
    "@ionic-native/core": "3.6.1",
    "@ionic-native/splash-screen": "3.4.2",
    "@ionic-native/status-bar": "3.4.2",
    "@ionic/storage": "2.0.1",
    "ionic-angular": "^3.1.1",
    "ionicons": "3.0.0",
    "rxjs": "^5.3.1",
    "sw-toolbox": "3.4.0",
    "zone.js": "^0.8.5"
  },
  "devDependencies": {
    "@ionic/app-scripts": "1.3.4",
    "typescript": "~2.2.1"
  },
  "homepage": "",
  "name": "Wakeb",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve",
    "watch": "ionic-app-scripts watch"
  },
  "-vs-binding": {
    "ProjectOpened": [
      "ionic:build",
      "ionic:serve"
    ]
  }
}

提前谢谢你。

【问题讨论】:

  • 您似乎没有添加@ionic-native/geolocation。安装了哪个版本?
  • 是的,你是对的,我没有添加@ionic-native/geolocation,添加后它现在可以工作了,谢谢。
  • ok.. 添加为答案

标签: angular ionic2 ionic3


【解决方案1】:

尝试删除您的node_modules 文件夹并运行新的npm install。您可能还想尝试运行 ionic plugin remove cordova-plugin-geolocation 并使用 ionic plugin add cordova-plugin-geolocation 重新添加

【讨论】:

    【解决方案2】:

    我没有添加@ionic-native/geolocation,添加后现在可以使用,谢谢。

    【讨论】:

      【解决方案3】:

      您的 package.json 丢失 @ionic-native/geolocation

      做:

       npm install --save @ionic-native/geolocation
      

      安装它。

      【讨论】:

        猜你喜欢
        • 2017-06-18
        • 1970-01-01
        • 2023-03-17
        • 2017-12-01
        • 1970-01-01
        • 2018-03-01
        • 2019-04-30
        • 2018-11-09
        • 1970-01-01
        相关资源
        最近更新 更多