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

后端 未结 14 2419
长发绾君心
长发绾君心 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:23

    First:

    npm uninstall @angular-devkit/build-angular
    

    Next:

    npm install @angular-devkit/build-angular@0.12.4
    
    0 讨论(0)
  • 2020-12-28 13:24

    go to package.json and change the version of @angular-devkit/build-angular as follows:

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

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

    I just deleted the node_module folder and run

    NPM Install

    and it worked fine for me.

    It is an Angular 9 solution.

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

    When upgrading Angular from version 10 to 8 I got very similar error, namely Schema validation failed with the following errors: Data path "" should NOT have additional properties(serverTarget)..

    The solution was remove all "serverTarget" references from below "serve". The below was wrong:

    "serve": {
      "builder": "@angular-devkit/build-angular:dev-server",
      "options": {
        "browserTarget": "my_app:build"
        "serverTarget": "my_app:server"
      },
      "configurations": {
        "production": {
          "browserTarget": "my_app:build:production",
          "serverTarget": "my_app:server:production"
        }
      }
    },
    

    The below is correct and compiled successfully:

    "serve": {
      "builder": "@angular-devkit/build-angular:dev-server",
      "options": {
        "browserTarget": "my_app:build"
      },
      "configurations": {
        "production": {
          "browserTarget": "my_app:build:production"
        }
      }
    },
    

    Bonus for those who are working with Angular Universal. If you want to run SSR on localhost, then indeed you need the serverTarget. However, for that you have to create a new section within the angular.json, something like:

    "serve-ssr": {
      "builder": "@nguniversal/builders:ssr-dev-server",
      "options": {
        "browserTarget": "my_app:build",
        "serverTarget": "my_app:server"
      },
      "configurations": {
        "production": {
          "browserTarget": "my_app:build:production",
          "serverTarget": "my_app:server:production"
        }
      }
    },
    

    Then ng run my_app:serve-ssr.

    Actually I got this error when upgrading Angular from version 10 into 8 and wanted to improve some things. Then I've messed up the serverTarget thing with that wrong thinking, hopefully this will help out someone with Angular Universal in a project.

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

    Remove these two lines from the angular.json file:

    "vendorSourceMap":"true",
    "evalSourceMap":"true".
    
    0 讨论(0)
  • 2020-12-28 13:29

    my app is on angular 7.2.3

    remove "es5BrowserSupport": true from angular.json. and npm start now works.

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