Angular 6 CLI not registering service workers












2















I followed this guide: https://angular.io/guide/service-worker-getting-started



In an existing Angular CLI app I ran



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



ng build --prod



npm start -c-1 dist/<project-name>



Chrome Dev tools > Application
Manifest - detected, no errors or warnings
Service Workers - empty



Network tab loads every file with 200



ngsw-config.json - exists generated by the command
assets/icons - directory generated
app.module.ts - imports array contains ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production })



Running PWA audit returns an error with ServiceWorker not registered.










share|improve this question























  • I did notice that executing the same exact steps on a vm running Linux had actually worked and the service worker was registered. Windows seems to be not correctly registering the service worker

    – O.MeeKoh
    Oct 1 '18 at 13:27











  • I did the same thing as written in angular docs, and service worker is not registered inside chrome. Don't know how to fix this :/

    – tzm
    Nov 16 '18 at 0:36











  • have you guys found a solution to this? I have started running out of ideas...

    – MrfksIV
    Dec 5 '18 at 15:44











  • according to some users in github this is because some 3rd party libraries are changing some application state and it breaks service worker registration

    – karoluS
    Jan 15 at 0:20











  • Any chance you can drop a reference to these discussions?

    – O.MeeKoh
    Jan 16 at 16:08
















2















I followed this guide: https://angular.io/guide/service-worker-getting-started



In an existing Angular CLI app I ran



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



ng build --prod



npm start -c-1 dist/<project-name>



Chrome Dev tools > Application
Manifest - detected, no errors or warnings
Service Workers - empty



Network tab loads every file with 200



ngsw-config.json - exists generated by the command
assets/icons - directory generated
app.module.ts - imports array contains ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production })



Running PWA audit returns an error with ServiceWorker not registered.










share|improve this question























  • I did notice that executing the same exact steps on a vm running Linux had actually worked and the service worker was registered. Windows seems to be not correctly registering the service worker

    – O.MeeKoh
    Oct 1 '18 at 13:27











  • I did the same thing as written in angular docs, and service worker is not registered inside chrome. Don't know how to fix this :/

    – tzm
    Nov 16 '18 at 0:36











  • have you guys found a solution to this? I have started running out of ideas...

    – MrfksIV
    Dec 5 '18 at 15:44











  • according to some users in github this is because some 3rd party libraries are changing some application state and it breaks service worker registration

    – karoluS
    Jan 15 at 0:20











  • Any chance you can drop a reference to these discussions?

    – O.MeeKoh
    Jan 16 at 16:08














2












2








2








I followed this guide: https://angular.io/guide/service-worker-getting-started



In an existing Angular CLI app I ran



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



ng build --prod



npm start -c-1 dist/<project-name>



Chrome Dev tools > Application
Manifest - detected, no errors or warnings
Service Workers - empty



Network tab loads every file with 200



ngsw-config.json - exists generated by the command
assets/icons - directory generated
app.module.ts - imports array contains ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production })



Running PWA audit returns an error with ServiceWorker not registered.










share|improve this question














I followed this guide: https://angular.io/guide/service-worker-getting-started



In an existing Angular CLI app I ran



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



ng build --prod



npm start -c-1 dist/<project-name>



Chrome Dev tools > Application
Manifest - detected, no errors or warnings
Service Workers - empty



Network tab loads every file with 200



ngsw-config.json - exists generated by the command
assets/icons - directory generated
app.module.ts - imports array contains ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production })



Running PWA audit returns an error with ServiceWorker not registered.







angular-cli angular-cli-v6






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Sep 30 '18 at 23:44









O.MeeKohO.MeeKoh

85110




85110













  • I did notice that executing the same exact steps on a vm running Linux had actually worked and the service worker was registered. Windows seems to be not correctly registering the service worker

    – O.MeeKoh
    Oct 1 '18 at 13:27











  • I did the same thing as written in angular docs, and service worker is not registered inside chrome. Don't know how to fix this :/

    – tzm
    Nov 16 '18 at 0:36











  • have you guys found a solution to this? I have started running out of ideas...

    – MrfksIV
    Dec 5 '18 at 15:44











  • according to some users in github this is because some 3rd party libraries are changing some application state and it breaks service worker registration

    – karoluS
    Jan 15 at 0:20











  • Any chance you can drop a reference to these discussions?

    – O.MeeKoh
    Jan 16 at 16:08



















  • I did notice that executing the same exact steps on a vm running Linux had actually worked and the service worker was registered. Windows seems to be not correctly registering the service worker

    – O.MeeKoh
    Oct 1 '18 at 13:27











  • I did the same thing as written in angular docs, and service worker is not registered inside chrome. Don't know how to fix this :/

    – tzm
    Nov 16 '18 at 0:36











  • have you guys found a solution to this? I have started running out of ideas...

    – MrfksIV
    Dec 5 '18 at 15:44











  • according to some users in github this is because some 3rd party libraries are changing some application state and it breaks service worker registration

    – karoluS
    Jan 15 at 0:20











  • Any chance you can drop a reference to these discussions?

    – O.MeeKoh
    Jan 16 at 16:08

















I did notice that executing the same exact steps on a vm running Linux had actually worked and the service worker was registered. Windows seems to be not correctly registering the service worker

– O.MeeKoh
Oct 1 '18 at 13:27





I did notice that executing the same exact steps on a vm running Linux had actually worked and the service worker was registered. Windows seems to be not correctly registering the service worker

– O.MeeKoh
Oct 1 '18 at 13:27













I did the same thing as written in angular docs, and service worker is not registered inside chrome. Don't know how to fix this :/

– tzm
Nov 16 '18 at 0:36





I did the same thing as written in angular docs, and service worker is not registered inside chrome. Don't know how to fix this :/

– tzm
Nov 16 '18 at 0:36













have you guys found a solution to this? I have started running out of ideas...

– MrfksIV
Dec 5 '18 at 15:44





have you guys found a solution to this? I have started running out of ideas...

– MrfksIV
Dec 5 '18 at 15:44













according to some users in github this is because some 3rd party libraries are changing some application state and it breaks service worker registration

– karoluS
Jan 15 at 0:20





according to some users in github this is because some 3rd party libraries are changing some application state and it breaks service worker registration

– karoluS
Jan 15 at 0:20













Any chance you can drop a reference to these discussions?

– O.MeeKoh
Jan 16 at 16:08





Any chance you can drop a reference to these discussions?

– O.MeeKoh
Jan 16 at 16:08












1 Answer
1






active

oldest

votes


















2














I had the same issue. Adding this to main.ts resolved the problem.



platformBrowserDynamic().bootstrapModule(AppModule).then(() => {
if ('serviceWorker' in navigator && environment.production) {
navigator.serviceWorker.register('ngsw-worker.js');
}
}).catch(err => console.log(err))





share|improve this answer
























  • This hasn't worked for me

    – MrfksIV
    Dec 5 '18 at 15:46











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52583050%2fangular-6-cli-not-registering-service-workers%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














I had the same issue. Adding this to main.ts resolved the problem.



platformBrowserDynamic().bootstrapModule(AppModule).then(() => {
if ('serviceWorker' in navigator && environment.production) {
navigator.serviceWorker.register('ngsw-worker.js');
}
}).catch(err => console.log(err))





share|improve this answer
























  • This hasn't worked for me

    – MrfksIV
    Dec 5 '18 at 15:46
















2














I had the same issue. Adding this to main.ts resolved the problem.



platformBrowserDynamic().bootstrapModule(AppModule).then(() => {
if ('serviceWorker' in navigator && environment.production) {
navigator.serviceWorker.register('ngsw-worker.js');
}
}).catch(err => console.log(err))





share|improve this answer
























  • This hasn't worked for me

    – MrfksIV
    Dec 5 '18 at 15:46














2












2








2







I had the same issue. Adding this to main.ts resolved the problem.



platformBrowserDynamic().bootstrapModule(AppModule).then(() => {
if ('serviceWorker' in navigator && environment.production) {
navigator.serviceWorker.register('ngsw-worker.js');
}
}).catch(err => console.log(err))





share|improve this answer













I had the same issue. Adding this to main.ts resolved the problem.



platformBrowserDynamic().bootstrapModule(AppModule).then(() => {
if ('serviceWorker' in navigator && environment.production) {
navigator.serviceWorker.register('ngsw-worker.js');
}
}).catch(err => console.log(err))






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 27 '18 at 6:26









mdanacimdanaci

744




744













  • This hasn't worked for me

    – MrfksIV
    Dec 5 '18 at 15:46



















  • This hasn't worked for me

    – MrfksIV
    Dec 5 '18 at 15:46

















This hasn't worked for me

– MrfksIV
Dec 5 '18 at 15:46





This hasn't worked for me

– MrfksIV
Dec 5 '18 at 15:46




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52583050%2fangular-6-cli-not-registering-service-workers%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Contact image not getting when fetch all contact list from iPhone by CNContact

count number of partitions of a set with n elements into k subsets

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks