Schema validation failed with the following errors: Data path should NOT have additional properties

avatar
Borislav Hadzhiev

Last updated: Apr 4, 2024
4 min

banner

# Table of Contents

  1. Schema validation failed with the following errors: Data path should NOT have additional properties
  2. Remove deprecated properties from your angular.json file
  3. Try to update the versions of your packages
  4. Delete your node_modules and reinstall your dependencies

# Schema validation failed with the following errors: Data path should NOT have additional properties

The error "Error: Schema validation failed with the following errors: Data path "" should NOT have additional properties()" occurs for 2 main reasons:

  • Having a version mismatch between your node_modules and your package.json file.
  • Having deprecated properties in your angular.json file.

Here is the complete error message.

shell
Error: Schema validation failed with the following errors: Data path "" should NOT have additional properties(project). at MergeMapSubscriber._registry.compile.pipe.operators_1.concatMap.validatorResult

# Remove deprecated properties from your angular.json file

If you use Angular, make sure you don't have any deprecated properties set in your angular.json config file.

For example, if you get the error "Error: Schema validation failed with the following errors: Data path "" should NOT have additional properties(extractCss)", then you have to remove the deprecated extractCss property from your angular.json file.

Your angular.json file should be in the root directory of your project (right next to your package.json file).

Open the file and remove the deprecated properties, as indicated in your error messages.

Some of the properties that often cause the issue are:

  • extractCss
  • styleExt
  • sourceMap
  • vendorSourceMap
  • evalSourceMap
  • inlineStyleLanguage
  • es5BrowserSupport
  • serverTarget

You can use Ctrl + F (or Cmd + F) to search for these properties and remove them.

The property you have to remove should be between the parentheses () in your error message, e.g. "additional properties(extractCss)" means that you have to remove the deprecated property extractCss from angular.json.

# Try to update the versions of your packages

Open your terminal in your project's root directory (where your package.json) file is and try to update your packages.

shell
npm update npm update --all --force

npm update

After you run the command, update your Angular workspace and its dependencies.

shell
npx ng update

The command will show which commands you need to run to update your Angular packages.

run ng update command

For example, the screenshot above shows that I have to run the following commands.

shell
npx ng update @angular/cdk npx ng update @angular/cli npx ng update @angular/core npx ng ng update @angular/material

The Angular packages you have to update might be different, so make sure to follow the output of the npx ng update command.

# Delete your node_modules and reinstall your dependencies

If the error persists, delete your node_modules folder and your package-lock.json file and reinstall your dependencies.

If you are on macOS or Linux, issue the following commands in bash or zsh.

shell
# for macOS and Linux rm -rf node_modules rm -f package-lock.json rm -f yarn.lock # ๐Ÿ‘‡๏ธ clean your npm cache npm cache clean --force # ๐Ÿ‘‡๏ธ install packages npm install

If you are on Windows, issue the following commands in CMD.

cmd
# for Windows rd /s /q "node_modules" del package-lock.json del -f yarn.lock # ๐Ÿ‘‡๏ธ clean your npm cache npm cache clean --force # ๐Ÿ‘‡๏ธ install packages npm install

# Update all packages in your environment to the latest version

The error is most often caused by a version mismatch between packages.

You can try to update all packages in your environment to the latest version and see if the error is resolved.

First, make sure to stage and commit your changes because updating your npm packages to the latest version might cause issues if you rely on older package versions.

You can use the npm-check-updates command to update all packages.

Open your terminal in your project's root directory (where your package.json file is) and run the following command.

You can add your package.json file to version control (e.g. git) because the following 2 commands will update the versions of your packages in your package.json file.
shell
npx npm-check-updates -u npm install --legacy-peer-deps

The commands update all package versions in your package.json file to the latest version and install the packages.

Try to start your development server after making the change.

shell
npm start # or using the Angular CLI npx ng serve

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.

Copyright ยฉ 2024 Borislav Hadzhiev