Toof_LD
Toof_LD

Reputation: 72

Data path "" must NOT have additional properties(ngswConfigPath)

I downloaded example from angular.io and followed the tour: https://angular.io/guide/service-worker-getting-started#cli-command

ng add @angular/pwa   
ng build

I faced this error:

Error: Schema validation failed with the following errors:
  Data path "" must NOT have additional properties(ngswConfigPath).
E:\Personal Project\service-worker-example\node_modules\rxjs\dist\cjs\internal\util\reportUnhandledError.js:13
            throw err;
            ^

SchemaValidationException [Error]: Schema validation failed with the following errors:
  Data path "" must NOT have additional properties(ngswConfigPath).
    at E:\Personal Project\service-worker-example\node_modules\@angular-devkit\architect\src\architect.js:40:27 {
  errors: [
    {
      instancePath: '',
      schemaPath: '#/additionalProperties',
      keyword: 'additionalProperties',
      params: { additionalProperty: 'ngswConfigPath' },
      message: 'must NOT have additional properties'
    }
  ]
}

Here is my angular.json

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "angular.io-example": {
      "projectType": "application",
      "root": "",
      "sourceRoot": "src",
      "prefix": "app",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:application",
          "options": {
            "outputPath": "dist",
            "index": "src/index.html",
            "browser": "src/main.ts",
            "polyfills": ["zone.js"],
            "tsConfig": "tsconfig.app.json",
            "assets": [
              "src/favicon.ico",
              "src/assets",
              "src/manifest.webmanifest"
            ],
            "styles": [
              "src/styles.css"
            ],
            "scripts": [],
            "serviceWorker": true,
            "ngswConfigPath": "ngsw-config.json"
          },
          "configurations": {
            "production": {
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "500kb",
                  "maximumError": "1mb"
                },
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "2kb",
                  "maximumError": "4kb"
                }
              ],
              "outputHashing": "all",
              "serviceWorker": "ngsw-config.json"
            },
            "development": {
              "optimization": false,
              "extractLicenses": false,
              "sourceMap": true
            }
          },
          "defaultConfiguration": "production"
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "configurations": {
            "production": {
              "buildTarget": "angular.io-example:build:production"
            },
            "development": {
              "buildTarget": "angular.io-example:build:development"
            }
          },
          "defaultConfiguration": "development"
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "buildTarget": "angular.io-example:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "polyfills": ["zone.js", "zone.js/testing"],
            "tsConfig": "tsconfig.spec.json",
            "assets": [
              "src/favicon.ico",
              "src/assets",
              "src/manifest.webmanifest"
            ],
            "styles": [
              "src/styles.css"
            ],
            "scripts": []
          }
        },
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "e2e/protractor.conf.js",
            "devServerTarget": "angular.io-example:serve"
          },
          "configurations": {
            "production": {
              "devServerTarget": "angular.io-example:serve:production"
            }
          }
        }
      }
    }
  },
  "cli": {
    "analytics": "7cf21382-de23-496e-9cb0-b31c10d2ff0d"
  }
}

Please give me advice on this issue.

Thank you guys!

i was tried remove node_modules and reinstall but not working

I using angular v17

Upvotes: 0

Views: 509

Answers (1)

Yulia Galiulina
Yulia Galiulina

Reputation: 149

Remove the ngswConfigPath property. This must be an artifact of transitioning from the browser to application builder. Also remove this line "serviceWorker": true as it's invalid.

Upvotes: 0

Related Questions