"Property ngswConfigPath is not allowed" after updating from angular 16 to 17

Hi,
I updated my project from angular 16 to 17. Now the build command ends with an error:

> ionic build          
> ng.cmd run app:build
Error: Schema validation failed with the following errors:
  Data path "" must NOT have additional properties(ngswConfigPath).
[ERROR] An error occurred while running subprocess ng.
        
        ng.cmd run app:build exited with exit code 1.

In the file angular.json there are two lines
ngswConfigPath_not_allowed

BUT when I create a new blank project and add pwa service worker again, it adds the exact same properties into the angular.json file without showing any errrors! How to fix this?

What I tried so far:

1. Delete the node_modules folder.
2. Delete the package-lock.json.
3. Clean the npm cache with: npm cache clean --force
4. npm install

Another question is: can I copy all differences from angular.json file of the new blank project to the angular.json file of my current poject? e.g.:

found in new angular.json

  "builder": "@angular-devkit/build-angular:browser",

  or 

  "main": "src/main.ts",

found in old angular.json

  "builder": "@angular-devkit/build-angular:application",

  or 

  "browser": "src/main.ts"

Warning" Switching to esbuild ruins your project!

It happens when you press the button “Switch to esbuild” under Recommendations.

The following table lists all the browser builder options that will need to be adjusted or removed.
Angular esbuild

When I changed

    "serviceWorker": true,
    "ngswConfigPath": "ngsw-config.json",

to

    "serviceWorker":  "ngsw-config.json",

Ionic build could run again. But when you want to start the project again by “ionic serve” you get to see

[ng] 13:08:51 [vite] warning: 
[ng] E:/ionic-workspace/op24/.angular/cache/17.0.6/vite/deps/chunk-MWVXNVJO.js
[ng] 2585|      return i[n];
[ng] 2586|    }
[ng] 2587|    return import("./".concat(a, ".entry.js").concat("")).then(function(e2) {
[ng]    |                  ^
[ng] 2588|      {
[ng] 2589|        cmpModules.set(a, e2);
[ng] The above dynamic import cannot be analyzed by Vite.
[ng] See https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars#limitations for supported dynamic import formats. If this is intended to be left as-is, you can use the /* @vite-ignore */ comment inside the import() call to suppress this warning.
[ng]
[ng]   Plugin: vite:import-analysis

and in the browser you see:

How can I undo everything? Can I switch to the old build system?

2 Likes