After migrating application from angular 5 to 6, on running ng serve the following errors pop up.
Schema validation failed with the following errors:
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.