Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

“.builders['browser']” should have required property 'class'

After installing the dependencies successfully using npm install, I got the following error while running the server:

Schema validation failed with the following errors: Data path ".builders['browser']" should have required property 'class'.

After searching for a while, I think the problem is with "@angular-builders/custom-webpack".

The project was working good, but i accidentally deleted it and clone it again, then i got the error.

Here's the dev dependencies:

"devDependencies": {
    "@angular-builders/custom-webpack": "latest",
    "@angular-builders/dev-server": "latest",
    "@angular-devkit/build-angular": "~0.13.6",
    "@angular/cli": "~7.3.6",
    "@angular/compiler-cli": "~7.2.10",
    "@angular/language-service": "~7.2.10",
    "@biesbjerg/ngx-translate-extract": "~2.3.4",
    "@types/jasmine": "~3.3.12",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~11.11.4",
    "codelyzer": "~5.0.0-beta.1",
    "dotenv": "latest",
    "jasmine-core": "~3.3.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.0.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-cli": "~2.0.0",
    "karma-coverage-istanbul-reporter": "~2.0.0",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "~1.4.0",
    "protractor": "~5.4.2",
    "rxjs-tslint": "~0.1.7",
    "ts-node": "~8.0.3",
    "tslint": "~5.14.0",
    "typescript": "~3.2.0",
    "webpack": "~4.29.6"
}

And here's my angular.json file:

{
    "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
    "version": 1,
    "newProjectRoot": "projects",
    "projects": {
        "iShop": {
            "root": "",
            "sourceRoot": "src",
            "projectType": "application",
            "prefix": "app",
            "schematics": {
                "@schematics/angular:component": {
                    "styleext": "scss"
                }
            },
            "architect": {
                "build": {
                    "builder": "@angular-builders/custom-webpack:browser",
                    "options": {
                        "customWebpackConfig": {
                            "path": "extra-webpack.config.js"
                        },
                        "outputPath": "dist",
                        "index": "src/index.html",
                        "main": "src/main.ts",
                        "tsConfig": "src/tsconfig.app.json",
                        "polyfills": "src/polyfills.ts",
                        "assets": [
                            "src/favicon.ico",
                            "src/apple-touch-icon.png",
                            "src/robots.txt",
                            "src/manifest.json",
                            "src/assets"
                        ],
                        "styles": [
                            "src/main.scss",
                            "src/assets/css/paymentfont/paymentfont.min.css",
                            "./node_modules/font-awesome/css/font-awesome.css",
                            "./node_modules/@ng-select/ng-select/themes/default.theme.css"
                        ],
                        "scripts": []
                    }
                },
                "serve": {
                    "builder": "@angular-builders/dev-server:generic",
                    "options": {
                        "browserTarget": "iShop:build"
                    },
                    "configurations": {
                        "production": {
                            "browserTarget": "iShop:build:production"
                        }
                    }
                }
            }
        },
        "iShop-e2e": {
            "root": "e2e",
            "projectType": "application",
            "architect": {
                "e2e": {
                    "builder": "@angular-devkit/build-angular:protractor",
                    "options": {
                        "protractorConfig": "e2e/protractor.conf.js",
                        "devServerTarget": "iShop:serve"
                    }
                },
                "lint": {
                    "builder": "@angular-devkit/build-angular:tslint",
                    "options": {
                        "tsConfig": [
                            "e2e/tsconfig.e2e.json"
                        ],
                        "exclude": [
                            "**/node_modules/**"
                        ]
                    }
                }
            }
        }
    },
    "defaultProject": "iShop"
}

And my angular CLI version is: 7.3.9

like image 247
Ayoub k Avatar asked Jul 16 '19 15:07

Ayoub k


2 Answers

In my case, it was a dependency version problem.
I changed the following dependencies version from:

"@angular-builders/custom-webpack": "latest"
"@angular-builders/dev-server": "latest"

to:

"@angular-builders/custom-webpack": "~7.4.3"
"@angular-builders/dev-server": "~7.3.1"
like image 76
Ayoub k Avatar answered Sep 21 '22 14:09

Ayoub k


I came across the same error. But in my case I needed to use "@angular-builders/custom-webpack:dev-server" builder, which seems to be only available for Angular CLI 8+. I.e. I have to upgrade to Angular 8 first.

Your case should be simpler, as you only use "custom-webpack:browser", which is available in version 7

So try the following: change versions of "@angular-builders/custom-webpack" and "@angular-builders/dev-server" in package.json to ^7.3.0 (or higher, but not version 8), run npm install or yarn and try building again.

Source: https://github.com/manfredsteyer/ngx-build-plus/issues/109

like image 44
Alexey Grinko Avatar answered Sep 21 '22 14:09

Alexey Grinko