Angular ServiceWorkers + MIME type error

前端 未结 2 1315
忘掉有多难
忘掉有多难 2021-02-19 13:55

I\'m trying to add service workers to our existing angular (5.2, CLI 1.7.1) application. I did everything I was suppose to:

  1. I created ngsw-config.json
2条回答
  •  别那么骄傲
    2021-02-19 14:31

    After trying a lot of different things with Angular8 I finally upgraded angular-devkit from 0.800.2 to 0.803.2

    npm install @angular-devkit/build-angular@latest

    Then I got an error:

    Error: Expected to find an ngsw-config.json configuration file in the [PROJECT] folder. Either provide one or disable Service Worker in your angular.json configuration file.

    I fixed this by changing

    "ngswConfigPath": "ngsw-config.json" to "ngswConfigPath": "src/ngsw-config.json"

    Then it finally worked.

提交回复
热议问题