Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App won't build with service worker after updating to v6 #23692

Closed
Ploppy3 opened this issue May 4, 2018 · 7 comments
Closed

App won't build with service worker after updating to v6 #23692

Ploppy3 opened this issue May 4, 2018 · 7 comments
Labels
freq2: medium regression Indicates than the issue relates to something that worked in a previous version type: bug/fix
Milestone

Comments

@Ploppy3
Copy link

Ploppy3 commented May 4, 2018

I'm submitting a...


[x] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
[ ] Other... Please describe:

Current behavior

App does not build with a service worker

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

Expected behavior

App should build with service worker enabled after updading to v6.

Minimal reproduction of the problem with instructions

Update an ng5 app with a service worker to ng6 using https://update.angular.io/

Build the app:
ng build --prod

NB: I even tried to set up the service worker again with the new @angular/pwa package as described here: https://angular.io/guide/service-worker-getting-started#adding-a-service-worker-to-your-project

NB: The docs says that the ngsw-config.json is located in the src folder (https://angular.io/guide/service-worker-config#service-worker-configuration)
While the error says it should be located at the root of the project. The @angular/pwa create the file at the root ; moving the ngsw-config.json file to the src folder does not fix the issue.

Environment


Angular CLI: 6.0.0                                            
Node: 8.9.4                                                   
OS: win32 x64                                                 
Angular: 6.0.0                                                
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, http, language-service, material, platform-browser 
... platform-browser-dynamic, platform-server, router         
... service-worker                                            
                                                              
Package                           Version                     
-----------------------------------------------------------   
@angular-devkit/architect         0.6.0                       
@angular-devkit/build-angular     0.6.0                       
@angular-devkit/build-optimizer   0.6.0                       
@angular-devkit/core              0.6.0                       
@angular-devkit/schematics        0.6.0                       
@angular/pwa                      0.6.0                       
@ngtools/webpack                  6.0.0                       
@schematics/angular               0.6.0                       
@schematics/update                0.6.0                       
rxjs                              6.1.0                       
typescript                        2.7.2                       
webpack                           4.6.0                       
@boradakash
Copy link

boradakash commented May 4, 2018

I have also experienced the same error after upgrading to v6,
and that issue looks related to path of angular service worker config file(ngsw-config.json)
When I updated v6 using ng update it has created following path in angular.json file
"ngswConfigPath": "/src/ngsw-config.json",
then I changed to this
"ngswConfigPath": "src/ngsw-config.json",
and then I am able to build it successfully :)
Hope that helps!

@Ploppy3
Copy link
Author

Ploppy3 commented May 4, 2018

@boradakash Yeah, you're right the ngsw-config.json has to be in the src folder and your config fix did the trick for me. I'm successfully able to build again.

@ngbot ngbot bot added this to the needsTriage milestone May 4, 2018
@manughub manughub added regression Indicates than the issue relates to something that worked in a previous version freq2: medium labels May 4, 2018
@ngbot ngbot bot modified the milestones: needsTriage, Backlog May 4, 2018
@manughub
Copy link
Contributor

manughub commented May 4, 2018

We're on it.

@whyvrafvr
Copy link

thx @boradakash

@ranbuch
Copy link

ranbuch commented Feb 19, 2019

I was having the same problem when my config file configure like this:
"ngswConfigPath": "src/ngsw-config.json"
I was trying to build ng b --prod from src/app/shared instead of building from the root folder.
Building from the root folder fix the issue for me.

@alxhub
Copy link
Member

alxhub commented Feb 19, 2019

I'm closing this as I believe the issue to be fixed. As I've tested with Angular 7, ng add @angular/pwa seems to do the right thing and put the ngsw-config.json in root.

@alxhub alxhub closed this as completed Feb 19, 2019
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
freq2: medium regression Indicates than the issue relates to something that worked in a previous version type: bug/fix
Projects
None yet
Development

No branches or pull requests

7 participants