I did everything as written in \"https://angular.io/guide/service-worker-getting-started\" to make my application PWA.
Used exactly this commands:
n
artemisian's solution works but it's a hack, and you're not sure if it will work in the future.
A better solution
There is a 'registrationStrategy' setting which has to do with angular waiting with the registration until your app is 'stable'. Now if you have a bunch of stuff loading while starting your app (authenticating and building websocket connections) angular apparently thinks your app never is stable.
Fortunately you can override the registrationStrategy to registerImmediately like so:
ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production, registrationStrategy: 'registerImmediately' }),
See for the documentation here
After this the serviceworker will load, whatever the state of your app. There's also an option to pass an observable, so you can have it loaded whenever you think it's right.