简体   繁体   中英

Angular error installing service worker to an existing app

I need to install a service worker in my Angular 6 application. I run the following command: ng add @angular/pwa --project fire but after some times no service worker is added and this is the result:

@angular/pwa@0.10.6 updated 1 package and audited 36760 packages in 11.742s found 0 vulnerabilities

Installed packages for tooling via npm. Maximum call stack size exceeded

or

Installed packages for tooling via npm. Expected a synchronous delegate but got an asynchronous one.

This is my current configuration:

Angular CLI: 6.2.4
Node: 10.9.0
OS: win32 x64
Angular: 6.0.5
... core

Package                             Version
-------------------------------------------------------------
@angular-devkit/architect           0.8.4
@angular-devkit/build-angular       0.8.3
@angular-devkit/build-optimizer     0.8.3
@angular-devkit/build-webpack       0.8.3
@angular-devkit/core                0.8.4
@angular-devkit/schematics          0.8.4
@angular/animations                 6.0.6
@angular/cdk                        6.4.7
@angular/cli                        6.2.4
@angular/common                     6.0.6
@angular/compiler                   6.0.6
@angular/compiler-cli               6.0.6
@angular/forms                      6.0.6
@angular/http                       6.0.6
@angular/material                   6.4.7
@angular/material-moment-adapter    6.3.0
@angular/platform-browser           6.0.6
@angular/platform-browser-dynamic   6.0.6
@angular/platform-server            6.0.6
@angular/pwa                        0.10.6
@angular/router                     6.0.6
@ngtools/webpack                    6.2.3
@schematics/angular                 0.8.4
@schematics/update                  0.8.4
rxjs                                6.2.1
typescript                          2.7.2
webpack                             4.20.2

单独安装Service Worker可能会解决我的问题: ng g service-worker

Run below command

ng add @angular/pwa --project YOUR_PROJECT_NAME

below command will work only when the project and package version will be the same.

ng add @angular/pwa --project YOUR_PROJECT_NAME

your Angular version is 6.0.5. first, upgrade it to Angular 7 and then use the above command and it will work perfectly. Also, if you don't want to update. you have to run above

ng add @angular/pwa@VERSION6 --project YOUR_PROJECT_NAME

for me helped to install the most current version of the pwa:

ng add @angular/pwa@15.0.4

The list of the angular/pwa versions can be found here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM