Service workers are meant to run on production builds over https. But we want to test on localhost. Below some possible troubleshooting.

This post assumes you have already ran:

ng add @angular/pwa --project *project-name*

A few steps are required to getting your service worker installed on your localhost.

ngsw-worker.js not found

Firstly, make sure in your angular.json file the following is present: "ServiceWorker": true

          "configurations": {
            "production": {
              "serviceWorker": true,
              "fileReplacements":
                ...

Second, install http-server and run

http-server -p 8080 -c-1 dist/app

Third, your service workers might not work on ip-addresses. Therefore, you should used the following instead:

http://localhost:8080/

Go to DevTools > applications > Service workers to see if your ngsw-worker is found correctly. 

Angular service worker