After migrating application from angular 5 to 6, on running ng serve the following errors pop up.
Schema validation failed with the following errors:
First:
npm uninstall @angular-devkit/build-angular
Next:
npm install @angular-devkit/build-angular@0.12.4
go to package.json
and change the version of @angular-devkit/build-angular as follows:
@angular-devkit/build-angular": "^0.12.4"
I just deleted the node_module folder and run
NPM Install
and it worked fine for me.
It is an Angular 9 solution.
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.
Remove these two lines from the angular.json file:
"vendorSourceMap":"true",
"evalSourceMap":"true".
my app is on angular 7.2.3
remove "es5BrowserSupport": true from angular.json. and npm start now works.