Error: Schema validation failed with the following errors: Data path “” should NOT have additional properties(project)

后端 未结 14 2420
长发绾君心
长发绾君心 2020-12-28 12:46

After migrating application from angular 5 to 6, on running ng serve the following errors pop up.

Schema validation failed with the following errors:

相关标签:
14条回答
  • 2020-12-28 13:30

    Change package.json from:

    "@angular-devkit/build-angular": "^0.13.5",
    

    to:

    "@angular-devkit/build-angular": "^0.12.1",
    
    0 讨论(0)
  • 2020-12-28 13:35

    When i was getting version error issues,Following command worked for me:

    First run:

    npm update
    

    Second run:

    ng update
    

    Third run: (It will update all the mismatching packages)

    ng update --all --force
    
    0 讨论(0)
  • 2020-12-28 13:37

    The issue is generally because of a version mismatch in your package.json file.

    In my Angular 7 app, I have changed "@angular-devkit/build-angular": "^0.800.2" to "@angular-devkit/build-angular": "~0.7.0".

    Then I ran the command npm install after deleting node_modules.

    Aside: Use ^ carefully. Your working code may not work in the future if there is a major change in the package used.

    0 讨论(0)
  • 2020-12-28 13:39

    the format of angular.json needs to be as per Angular6... You can check my angular.json below or create a new project in Angular6 and then check the format of the 'project' head

    {
      "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
      "version": 1,
      "newProjectRoot": "projects",
      "projects": {
        "homePage6": {
          "root": "",
          "sourceRoot": "src",
          "projectType": "application",
          "prefix": "app",
          "schematics": {
            "@schematics/angular:component": {
              "styleext": "scss"
            }
          },
          "architect": {
            "build": {
              "builder": "@angular-devkit/build-angular:browser",
              "options": {
                "outputPath": "dist/homePage6",
                "index": "src/index.html",
                "main": "src/main.ts",
                "polyfills": "src/polyfills.ts",
                "tsConfig": "src/tsconfig.app.json",
                "assets": [
                  "src/favicon.ico",
                  "src/assets",
                  "src/manifest.json"
                ],
                "styles": [
                  "src/styles.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,
                  "serviceWorker": true
                }
              }
            },
            "serve": {
              "builder": "@angular-devkit/build-angular:dev-server",
              "options": {
                "browserTarget": "homePage6:build"
              },
              "configurations": {
                "production": {
                  "browserTarget": "homePage6:build:production"
                }
              }
            },
            "extract-i18n": {
              "builder": "@angular-devkit/build-angular:extract-i18n",
              "options": {
                "browserTarget": "homePage6: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": [
                  "styles.scss"
                ],
                "scripts": [],
                "assets": [
                  "src/favicon.ico",
                  "src/assets",
                  "src/manifest.json"
                ]
              }
            },
            "lint": {
              "builder": "@angular-devkit/build-angular:tslint",
              "options": {
                "tsConfig": [
                  "src/tsconfig.app.json",
                  "src/tsconfig.spec.json"
                ],
                "exclude": [
                  "**/node_modules/**"
                ]
              }
            }
          }
        },
        "homePage6-e2e": {
          "root": "e2e/",
          "projectType": "application",
          "architect": {
            "e2e": {
              "builder": "@angular-devkit/build-angular:protractor",
              "options": {
                "protractorConfig": "e2e/protractor.conf.js",
                "devServerTarget": "homePage6:serve"
              }
            },
            "lint": {
              "builder": "@angular-devkit/build-angular:tslint",
              "options": {
                "tsConfig": "e2e/tsconfig.e2e.json",
                "exclude": [
                  "**/node_modules/**"
                ]
              }
            }
          }
        }
      },
      "defaultProject": "homePage6"
    }

    I ran into similar (not identical, but also in angular.json) issue:

    Schema validation failed with the following errors: Data path "['server']" should NOT have additional properties(scripts). Error: Schema validation failed with the following errors: Data path "['server']" should NOT have additional properties(scripts). at MergeMapSubscriber._registry.compile.pipe.operators_1.concatMap.validatorResult [as project] (D:\Angular7\uHome\node_modules@angular-devkit\core\src\workspace\workspace.js:215:42) at MergeMapSubscriber._tryNext (D:\Angular7\uHome\node_modules\rxjs\internal\operators\mergeMap.js:69:27) at MergeMapSubscriber._next (D:\Angular7\uHome\node_modules\rxjs\internal\operators\mergeMap.js:59:18) at MergeMapSubscriber.Subscriber.next (D:\Angular7\uHome\node_modules\rxjs\internal\Subscriber.js:67:18) at MergeMapSubscriber.notifyNext (D:\Angular7\uHome\node_modules\rxjs\internal\operators\mergeMap.js:92:26) at InnerSubscriber._next (D:\Angular7\uHome\node_modules\rxjs\internal\InnerSubscriber.js:28:21) at InnerSubscriber.Subscriber.next (D:\Angular7\uHome\node_modules\rxjs\internal\Subscriber.js:67:18) at MapSubscriber._next (D:\Angular7\uHome\node_modules\rxjs\internal\operators\map.js:55:26) at MapSubscriber.Subscriber.next (D:\Angular7\uHome\node_modules\rxjs\internal\Subscriber.js:67:18) at SwitchMapSubscriber.notifyNext (D:\Angular7\uHome\node_modules\rxjs\internal\operators\switchMap.js:86:26)

    had to remove the property scripts from my angular.json... sharing this information to help someone in the future.

    0 讨论(0)
  • 2020-12-28 13:40

    I think it's with RxJS's incompatibility. You should install rxjs-compat to fix this.

    npm install rxjs-compat
    

    Also, the name of the file is angular.json and not .angular.json

    0 讨论(0)
  • 2020-12-28 13:44

    Updating npm and angular fixed mine:

    Assuming you use npm

    npm update
    

    then run:

    ng update
    

    NB: You might be prompted to update individual dependencies. In my case, I was prompted to run:

    ng update @angular/cli and ng update @angular/core.

    0 讨论(0)
提交回复
热议问题