Angular 将 Service Worker 安装到现有应用时出错

Angular error installing service worker to an existing app

我需要在我的 Angular 6 应用程序中安装一个 service worker。 我 运行 以下命令: ng add @angular/pwa --project fire 但一段时间后没有添加服务人员,结果如下:

@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

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

这是我当前的配置:

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

运行 命令下方

ng 添加@angular/pwa --project YOUR_PROJECT_NAME

以下命令仅在项目和包版本相同时才有效。

ng add @angular/pwa --project YOUR_PROJECT_NAME

您的 Angular 版本是 6.0.5。首先,将其升级到 Angular 7 ,然后使用上面的命令,它将完美运行。 另外,如果你不想更新。你必须 运行 以上

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