【问题标题】:Ionic problem: [ng]Schema validation failed with the following errors:[ng]Data path".builders['app-shell']"should have required property 'class'离子问题:[ng]Schema 验证失败,出现以下错误:[ng]Data path".builders['app-shell']"should have required property 'class'
【发布时间】:2019-10-23 16:17:00
【问题描述】:

在我将 ionic4 更新为 ionic5 并尝试运行 ionic 应用程序后,服务器已损坏并显示此错误:

[ng] 架构验证失败并出现以下错误:[ng] 数据 路径“.builders['app-shell']”应该具有必需的属性“类”。

[ERROR] ng 意外关闭(退出代码 1)。


我正在尝试更改 @angular-devkit/build-angular 节点包,因为我已通过将我的回退从 ^0.800.0 回滚到 ^0.12.4 来解决此问题。 通过这种方式: npm uninstall @angular-devkit/build-angular npm install @angular-devkit/build-angular@0.12.4 通过这种方式:

"@angular-devkit/build-angular": "^0.800.0"

"@angular-devkit/build-angular": "^0.10.0"

它解决了问题,但给了我这个错误:

[ng] 架构验证失败并出现以下错误:[ng] 数据 路径“”不应该有额外的属性(es5BrowserSupport)。

[ERROR] ng 意外关闭(退出代码 1)。

还是不行


这是 json 包:

`{
  "name": "ionicchattingapp",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "https://ionicframework.com/",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "^7.2.2",
    "@angular/core": "^7.2.2",
    "@angular/forms": "^7.2.2",
    "@angular/http": "^7.2.2",
    "@angular/platform-browser": "^7.2.2",
    "@angular/platform-browser-dynamic": "^7.2.2",
    "@angular/router": "^7.2.2",
    "@ionic-native/core": "^5.0.0",
    "@ionic-native/splash-screen": "^5.0.0",
    "@ionic-native/status-bar": "^5.0.0",
    "@ionic/angular": "^4.1.0",
    "cordova-android": "7.1.4",
    "cordova-plugin-device": "^2.0.2",
    "cordova-plugin-ionic-keyboard": "^2.1.3",
    "cordova-plugin-ionic-webview": "^3.1.2",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-statusbar": "^2.4.2",
    "cordova-plugin-whitelist": "^1.3.3",
    "core-js": "^2.5.4",
    "rxjs": "~6.3.3",
    "zone.js": "~0.8.29"
  },
  "devDependencies": {
    "@angular-devkit/architect": "~0.12.3",
    "@angular-devkit/build-angular": "0.12.4",
    "@angular-devkit/core": "~7.2.3",
    "@angular-devkit/schematics": "~7.2.3",
    "@angular/cli": "~7.3.1",
    "@angular/compiler": "~7.2.2",
    "@angular/compiler-cli": "~7.2.2",
    "@angular/language-service": "~7.2.2",
    "@ionic/angular-toolkit": "~1.4.0",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~10.12.0",
    "codelyzer": "~4.5.0",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~3.1.4",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.4.0",
    "ts-node": "~8.0.0",
    "tslint": "~5.12.0",
    "typescript": "~3.1.6"
  },
  "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": {}
    },
    "platforms": [
      "android"
    ]
  },
  "main": "index.js",
  "repository": {
    "type": "git",
    "url": "\u0016git remote add origin https://github.com/Omar-Sh1/nodeChatApp.git\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[A\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b\u001b[B"
  },
  "keywords": [
    "chatting"
  ],
  "license": "ISC"
}
`

这是 Angular json:

{
  "$schema": "./node_modules/@angular-devkit/core/src/workspace/workspace-schema.json",
  "version": 1,
  "defaultProject": "app",
  "newProjectRoot": "projects",
  "projects": {
    "app": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "prefix": "app",
      "schematics": {},
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "progress": false,
            "outputPath": "www",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.app.json",
            "assets": [
              {
                "glob": "**/*",
                "input": "src/assets",
                "output": "assets"
              },
              {
                "glob": "**/*.svg",
                "input": "node_modules/ionicons/dist/ionicons/svg",
                "output": "./svg"
              }
            ],
            "styles": [
              {
                "input": "src/theme/variables.scss"
              },
              {
                "input": "src/global.scss"
              }
            ],
            "scripts": []
          },
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "app:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "app:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "app:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.spec.json",
            "karmaConfig": "src/karma.conf.js",
            "styles": [],
            "scripts": [],
            "assets": [
              {
                "glob": "favicon.ico",
                "input": "src/",
                "output": "/"
              },
              {
                "glob": "**/*",
                "input": "src/assets",
                "output": "/assets"
              }
            ]
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "src/tsconfig.app.json",
              "src/tsconfig.spec.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        },
        "ionic-cordova-build": {
          "builder": "@ionic/angular-toolkit:cordova-build",
          "options": {
            "browserTarget": "app:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "app:build:production"
            }
          }
        },
        "ionic-cordova-serve": {
          "builder": "@ionic/angular-toolkit:cordova-serve",
          "options": {
            "cordovaBuildTarget": "app:ionic-cordova-build",
            "devServerTarget": "app:serve"
          },
          "configurations": {
            "production": {
              "cordovaBuildTarget": "app:ionic-cordova-build:production",
              "devServerTarget": "app:serve:production"
            }
          }
        }
      }
    },
    "app-e2e": {
      "root": "e2e/",
      "projectType": "application",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "e2e/protractor.conf.js",
            "devServerTarget": "app:serve"
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": "e2e/tsconfig.e2e.json",
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    }
  },
  "cli": {
    "defaultCollection": "@ionic/angular-toolkit"
  },
  "schematics": {
    "@ionic/angular-toolkit:component": {
      "styleext": "scss"
    },
    "@ionic/angular-toolkit:page": {
      "styleext": "scss"
    }
  }
}

【问题讨论】:

  • 您可能需要提供更多代码才能理解这一点。
  • @JGFMK 我正在编辑我希望更清楚的问题
  • 我将 package.json 从 "@angular-devkit/build-angular": "^0.800.1" 更新为 "@angular-devkit/build-angular": "^0.12.4" 运行“npm install”,它为我修复了它。
  • @tkerwood 终于成功了,谢谢

标签: angular ionic-framework


【解决方案1】:

从上述评论会议@tkerwood 提供解决方案。

package.json"@angular-devkit/build-angular": "^0.800.1" 更新为 "~0.13.9"

运行npm install

【讨论】:

  • 谁能解释一下为什么会有 800 版?我想不出有什么理由跳过 68 个版本
  • 我必须移动到版本“~0.13.9”才能工作npmjs.com/package/@angular-devkit/build-angular/v/0.13.9我选择了不在 800 范围内的最高版本号
  • @PieterDeBie 他们跳了超过 68 个版本,从 13 到 800 :P 原因是 Angular 生态系统中的人们喜欢共享相同的版本号。 0.800 版适用于 Angular 8,0.900 版适用于 Angular 9。0.13 版适用于 Angular 7。因此,如果您使用的是 Angular 8+,则不应使用此解决方案,请查看其他回复并使用与您的匹配的 devkit 版本CLI 版本
  • @LeroyMeijer 版本“~0.13.9”是 Angular 7 的最新版本
【解决方案2】:

大家都在关注将@angular-devkit/build-angular 版本降级到X,或者将@angular/cli 版本升级到Y 或最新版本。

但是,请不要盲目尝试切换X or Y or latest(虽然通常情况下,降级 devkit 应该会更好,因为升级 CLI 是一项重大更改)

要选择的正确版本始终取决于您的 Angular (angular-cli) 版本。我在这里列出了几个版本。

Angular CLI v8.3.19 -> 0.803.19
Angular CLI v8.3.17 -> 0.803.17
Angular CLI v7.3.8 -> 0.13.8
Angular CLI v6-lts -> 0.8.9

其他具体版本请访问:https://github.com/angular/angular-cli/tags。这可能需要一些挖掘,但是一旦你找到你的 CLI 版本,在一些标签中他们确实提到了 @angular-devkit/** 包的相应版本。

注意:如果你想升级你的 CLI 版本,你应该首先考虑升级到最新的主要版本,不要简单地跳到下一个主要版本。 *答案来自zhuhang.jasper

【讨论】:

  • 恕我直言,这是一个比投票份额大的答案更好的答案。但是,标签网站对我来说不是很清楚,哦!!!
  • 谢谢。你拯救了我的一天(更严格地说:两天)哈哈。
【解决方案3】:

Angular Cli 8 支持 Node Js 10.9+。我有 Node.js 8,更新到 10.16 后工作正常。

【讨论】:

    【解决方案4】:

    这对我也有用,

    1. npm 卸载 @angular-devkit/build-angular
    2. npm install @angular-devkit/build-angular@0.12.4

    【讨论】:

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