Service-worker can not be found

HI,

when trying to import “service-worker” from @angular the module can not be found.
when I try to

import { ServiceWorkerModule } from '@angular/service-worker';

The system does not find the package.

Is there a special package I need to install to add “service-worker” to an exsisting angular/project ?

Thanks


When I run:

ng add @angular/pwa --project app

The result is:

Installing packages for tooling via npm.
Installed packages for tooling via npm.
ERROR! src/manifest.webmanifest already exists.
ERROR! src/assets/icons/icon-128x128.png already exists.
ERROR! src/assets/icons/icon-144x144.png already exists.
ERROR! src/assets/icons/icon-152x152.png already exists.
ERROR! src/assets/icons/icon-192x192.png already exists.
ERROR! src/assets/icons/icon-512x512.png already exists.
ERROR! src/assets/icons/icon-72x72.png already exists.
The Schematic workflow failed. See above.
Ionic:

   Ionic CLI                     : 6.3.0 (C:\Users\user\AppData\Roaming\npm\node_modules\@ionic\cli)
   Ionic Framework               : @ionic/angular 5.0.7
   @angular-devkit/build-angular : 0.803.25
   @angular-devkit/schematics    : 9.1.0
   @angular/cli                  : 9.1.0
   @ionic/angular-toolkit        : 2.2.0

Utility:

   cordova-res : not installed
   native-run  : not installed

System:

   NodeJS : v12.16.1 (C:\Program Files\nodejs\node.exe)
   npm    : 6.13.4
   OS     : Windows 10
Package                            Current    Wanted   Latest  Location
@angular-devkit/build-angular     0.803.25  0.803.25  0.901.0  BLSProtocols_B
@types/jasmine                      3.3.16    3.3.16   3.5.10  BLSProtocols_B
@types/node                          8.9.5     8.9.5   13.9.5  BLSProtocols_B
core-js                             2.6.11    2.6.11    3.6.4  BLSProtocols_B
jasmine-core                         3.4.0     3.4.0    3.5.0  BLSProtocols_B
jasmine-spec-reporter                4.2.1     4.2.1    5.0.1  BLSProtocols_B
karma                                4.1.0     4.1.0    4.4.1  BLSProtocols_B
karma-chrome-launcher                2.2.0     2.2.0    3.1.0  BLSProtocols_B
karma-coverage-istanbul-reporter     2.0.6     2.0.6    2.1.1  BLSProtocols_B
karma-jasmine                        2.0.1     2.0.1    3.1.1  BLSProtocols_B
ts-node                              7.0.1     7.0.1    8.8.1  BLSProtocols_B
tslint                              5.15.0    5.15.0    6.1.0  BLSProtocols_B

Can you list your package.json?

You should have @angular/service-worker listed in there.