Skip to content Skip to sidebar Skip to footer

Angular V8 Throw Error No Matching Service Worker Detected

I'm always get the error like below when using service worker with angular v8 which did not happend in v7 Below is my config package.json '@angular/animations': '~8.2.14',

Solution 1:

I found the issue. The network may not stable so service worker cant register. So to fix it simply add this config

ServiceWorkerModule.register("ngsw-worker.js", {
    enabled: environment.production,
    registrationStrategy: "registerImmediately"
})

Solution 2:

I think you may have missed

"/index.html" "/assets/**", or maybe your assets are in separate image folder(I can't be sure until i see folder structure) "/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)" in

    {
     "$schema": "./node_modules/@angular/service-worker/config/schema.json",
     "index": "/index.html",
    "assetGroups": [
     {
      "name": "app",
      "installMode": "prefetch",
      "resources": {
        "files": [
          "/assets/favicon.ico",
          "/index.html",
          "/manifest.json",
          "/*.css",
          "/*.js"
        ]
       }
     }, {
      "name": "assets",
      "installMode": "lazy",
      "updateMode": "prefetch",
      "resources": {
        "files": [
           "/assets/**",
           "/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)"
         ]
       }
      }
     ]
   }

Other than this there seems to be no difference.Although, I have tried same config as yours which was working correctly.

Solution 3:

You need to use

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

instead of

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

Post a Comment for "Angular V8 Throw Error No Matching Service Worker Detected"