【问题标题】:Ionic 2 - Importing @ionic-native/geolocation causes build to failIonic 2 - 导入 @ionic-native/geolocation 会导致构建失败
【发布时间】:2017-09-29 12:57:53
【问题描述】:

我做了什么:
我正在使用 Visual Studio,因此我通过添加以下内容编辑了 package.json 文件:
- cordova-plugin-geolocation(在 cordovaPlugins 数组内)
- @ionic-native/geolocation(内部依赖对象)

然后我去编辑 app.module.ts 文件,添加:

import { Geolocation } from '@ionic-native/geolocation';

此时,当我尝试运行浏览器仿真时,我会收到以下错误:

Failed to load resource: the server responded with a status of 404 (Not Found) : main.css
Failed to load resource: the server responded with a status of 404 (Not Found) : main.js
Failed to load resource: the server responded with a status of 404 (Not Found) : polyfills.js

另外,我尝试通过以下方式导入假包:

import { Geolocation } from '@ionic-native/dfsdfdsf';

而且我没有收到任何错误(当然,即使它什么也没做)。

【问题讨论】:

    标签: cordova ionic-framework ionic2 geolocation


    【解决方案1】:

    我放了

    "cordova-plugin-geolocation": "^2.4.3"
    

    在我的 package.json 的依赖项中。

    我已经在“cordovaPlugins”下找到了它,但似乎还不够。
    现在可以正常使用了。

    【讨论】:

      【解决方案2】:

      请尝试运行升级

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-10-03
        • 1970-01-01
        • 2019-12-01
        相关资源
        最近更新 更多