离子不起作用 - 不再存在的错误

时间:2018-02-17 11:13:13

标签: javascript cordova ionic-framework angular5

我正在尝试build我的Ionic应用,但终端会显示:

ionic build
Running app-scripts build:
[12:46:01]  build dev started ...
[12:46:01]  clean started ...
[12:46:01]  clean finished in 16 ms
[12:46:01]  copy started ...
[12:46:01]  deeplinks started ...
[12:46:01]  deeplinks finished in 62 ms
[12:46:01]  transpile started ...
[12:46:04]  typescript: C:/Users/TOYANSK/Documents/Projects/IBeautyme/src/app/services/perfil.service.ts, line: 3
            Cannot find module '../../models/perfil'.

       L2:  import { AngularFireDatabase } from "angularfire2/database";
       L3:  import { Perfil } from "../../models/perfil";

[12:46:04]  typescript: C:/Users/TOYANSK/Documents/Projects/IBeautyme/src/app/services/perfil.service.ts, line: 14
            Expected 0 type arguments, but got 1.

      L13:  getPerfil(uid){
      L14:      return this.db.list<Perfil>('/perfil/' + this.uid);

Error: Failed to transpile program
    at BuildError.Error (native)
    at new BuildError (C:\Users\TOYANSK\Documents\Projects\IBeautyme\node_modules\@ionic\app-scripts\dist\util\errors.js:16:28)
    at C:\Users\TOYANSK\Documents\Projects\IBeautyme\node_modules\@ionic\app-scripts\dist\transpile.js:159:20
    at transpileWorker (C:\Users\TOYANSK\Documents\Projects\IBeautyme\node_modules\@ionic\app-scripts\dist\transpile.js:107:12)
    at Object.transpile (C:\Users\TOYANSK\Documents\Projects\IBeautyme\node_modules\@ionic\app-scripts\dist\transpile.js:64:12)
    at C:\Users\TOYANSK\Documents\Projects\IBeautyme\node_modules\@ionic\app-scripts\dist\build.js:109:82
[12:46:04]  copy finished in 3.05 s

奇怪的是,第3行和第14行的错误都不在我的代码上了。如果我尝试runserve --lab,也会出现此类问题。

当我运行serve --lab时,我在控制台上也看到了这些错误:

Refused to apply style from 'http://localhost:8100/build/main.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
vendor.js 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)
localhost/:1 Refused to apply style from 'http://localhost:8100/build/main.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
vendor.js 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)
localhost/:1 Refused to apply style from 'http://localhost:8100/build/main.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

我的 package.json 是:

{
  "name": "IBeautyme",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "lint": "ionic-app-scripts lint",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/common": "5.0.1",
    "@angular/compiler": "5.0.1",
    "@angular/compiler-cli": "5.0.1",
    "@angular/core": "5.0.1",
    "@angular/forms": "5.0.1",
    "@angular/http": "5.0.1",
    "@angular/platform-browser": "5.0.1",
    "@angular/platform-browser-dynamic": "5.0.1",
    "@ionic-native/core": "4.4.0",
    "@ionic-native/geolocation": "4.2.1",
    "@ionic-native/google-maps": "4.2.1",
    "@ionic-native/network": "^4.5.2",
    "@ionic-native/splash-screen": "4.4.0",
    "@ionic-native/status-bar": "4.4.0",
    "@ionic/storage": "2.1.3",
    "angularfire2": "^4.0.0-rc.1",
    "cordova-android": "^6.3.0",
    "cordova-plugin-device": "^1.1.4",
    "cordova-plugin-geolocation": "^3.0.0",
    "cordova-plugin-googlemaps": "^2.1.1",
    "cordova-plugin-ionic-webview": "^1.1.16",
    "cordova-plugin-network-information": "^2.0.1",
    "cordova-plugin-splashscreen": "^4.0.3",
    "cordova-plugin-whitelist": "^1.3.1",
    "firebase": "^3.7.5",
    "ionic-angular": "3.9.2",
    "ionic-plugin-keyboard": "^2.2.1",
    "ionicons": "3.0.0",
    "rxjs": "5.5.2",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.18"
  },
  "devDependencies": {
    "@ionic/app-scripts": "3.1.2",
    "typescript": "^2.5.2"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "ionic-plugin-keyboard": {},
      "cordova-plugin-whitelist": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-webview": {},
      "cordova-plugin-googlemaps": {
        "API_KEY_FOR_ANDROID": "AIzaXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        "API_KEY_FOR_IOS": "AIzaXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
      },
      "cordova-plugin-geolocation": {},
      "cordova-plugin-network-information": {}
    },
    "platforms": [
      "android"
    ]
  }
}

1 个答案:

答案 0 :(得分:0)

尝试使用cordova选项运行。

ionic cordova build <platform>