无法在离子服务--devapp上解构“ undefined”的属性“ styles”

时间:2019-04-02 09:54:02

标签: angular cordova ionic-framework

尝试运行ionic serve --devapp时,出现此错误:

[ng] Cannot destructure property 'styles' of 'undefined' or 'null'.
[ng] TypeError: Cannot destructure property `styles` of 'undefined' or 'null'.
[ng]  at Object.getCommonConfig (.\node_modules\@angular-devkit\build-angular\src\angular-cli-files\models\webpack-configs\common.js:33:107)

我试图清理npm缓存,更新所有依赖项,删除package-lock.json,然后再次安装。几次。也尝试过npm ci。 似乎什么都没用。

这是我的package.json:

{
  "name": "myludopal",
  "version": "1.0.0",
  "author": "Mazus DEV",
  "homepage": "http://ionicframework.com/",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^7.2.11",
    "@angular/common": "^7.2.11",
    "@angular/core": "^7.2.11",
    "@angular/forms": "^7.2.11",
    "@angular/http": "^7.2.11",
    "@angular/platform-browser": "^7.2.11",
    "@angular/platform-browser-dynamic": "^7.2.11",
    "@angular/router": "^7.2.11",
    "@ionic-native/barcode-scanner": "^5.3.0",
    "@ionic-native/core": "^5.3.0",
    "@ionic-native/file": "^5.3.0",
    "@ionic-native/ionic-webview": "5.3.0",
    "@ionic-native/splash-screen": "^5.3.0",
    "@ionic-native/status-bar": "^5.3.0",
    "@ionic/angular": "^4.1.2",
    "@ionic/storage": "^2.2.0",
    "android-versions": "^1.4.0",
    "angular4-knob": "^1.1.11",
    "chart.js": "^2.8.0",
    "cordova": "^9.0.0",
    "cordova-android": "^8.0.0",
    "cordova-browser": "^6.0.0",
    "cordova-plugin-device": "^2.0.2",
    "cordova-plugin-file": "^6.0.1",
    "cordova-plugin-file-transfer": "^1.7.1",
    "cordova-plugin-ionic": "^5.3.0",
    "cordova-plugin-ionic-keyboard": "^2.1.3",
    "cordova-plugin-ionic-webview": "^4.0.1",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-statusbar": "^2.4.2",
    "cordova-plugin-whitelist": "^1.3.3",
    "core-js": "^3.0.0",
    "ionic-image-loader": "^7.0.0-beta.2",
    "lodash-es": "^4.17.11",
    "ngx-chips": "^2.0.0-beta.0",
    "phonegap-plugin-barcodescanner": "^8.0.1",
    "rxjs": "^6.4.0",
    "zone.js": "0.8.29"
  },
  "devDependencies": {
    "@angular-devkit/architect": "^0.13.7",
    "@angular-devkit/build-angular": "^0.13.7",
    "@angular-devkit/core": "^7.3.7",
    "@angular-devkit/schematics": "^7.3.7",
    "@angular/cli": "^7.3.7",
    "@angular/compiler": "^7.2.11",
    "@angular/compiler-cli": "^7.2.11",
    "@angular/language-service": "^7.2.11",
    "@ionic/angular-toolkit": "^1.5.0",
    "@types/jasmine": "^3.3.12",
    "@types/jasminewd2": "^2.0.6",
    "@types/lodash-es": "^4.17.3",
    "@types/node": "^11.13.0",
    "codelyzer": "^5.0.0",
    "jasmine-core": "^3.3.0",
    "jasmine-spec-reporter": "^4.2.1",
    "karma": "^4.0.1",
    "karma-chrome-launcher": "^2.2.0",
    "karma-coverage-istanbul-reporter": "^2.0.5",
    "karma-jasmine": "^2.0.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "protractor": "^5.4.2",
    "ts-node": "^8.0.3",
    "tslint": "^5.15.0",
    "typescript": "3.2.4"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-plugin-whitelist": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-webview": {
        "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
      },
      "cordova-plugin-ionic-keyboard": {},
      "phonegap-plugin-barcodescanner": {
        "ANDROID_SUPPORT_V4_VERSION": "27.+"
      },
      "cordova-plugin-file": {}
    },
    "platforms": [
      "browser",
      "android"
    ]
  }
}

在网上找不到与此相关的任何内容,通过查看错误,看来配置文件缺少'style'属性,我试图向上调用链,找到了这个文件,但是找不到不做。

其他构建命令有效:ng serveng build,甚至ionic cordova build android都可以使用...

我要运行的命令用于在devapp android应用程序中测试Ionic应用程序。

感谢任何想法。

2 个答案:

答案 0 :(得分:2)

我遇到了同样的问题,问题不完全是ionic,而是

@ionic/angular-toolkit,我将其从1.5.0降级为1.4.0,一切正常。

仅当您尝试以livereload模式运行时,才会发生错误。

答案 1 :(得分:0)

从4.09更新到ionic 4.12后,这里也存在同样的问题。

解决了升级到@ ionic / angula @ latest(4.2.0)