gkucmierz
gkucmierz

Reputation: 1145

Angular adding PWA causing problem with Angular Ivy

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 10.0.4
Node: 12.18.3
OS: darwin x64

Angular: 10.0.5
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
... service-worker
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.1000.4
@angular-devkit/build-angular     0.1000.4
@angular-devkit/build-optimizer   0.1000.4
@angular-devkit/build-webpack     0.1000.4
@angular-devkit/core              10.0.4
@angular-devkit/schematics        10.0.4
@angular/cli                      10.0.4
@ngtools/webpack                  10.0.4
@schematics/angular               10.0.4
@schematics/update                0.1000.4
rxjs                              6.5.5
typescript                        3.9.7
webpack                           4.43.0

I added ng add @angular/pwa to project.

And this line:

    ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production }),

In app.module.ts is causing problem:

    ERROR in node_modules/@angular/service-worker/service-worker.d.ts:15:22 - error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.
    
    This likely means that the library (@angular/service-worker) which declares ServiceWorkerModule has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.
    
    15 export declare class ServiceWorkerModule {
                            ~~~~~~~~~~~~~~~~~~~

How can I resolve that problem?

It is hard to add more details to overcome stackoverflow parser, while I added many details using angular version command.

Upvotes: 0

Views: 598

Answers (2)

gkucmierz
gkucmierz

Reputation: 1145

Looks like that helped

  "angularCompilerOptions": {
    "enableIvy": false
  }

Upvotes: 0

pbachman
pbachman

Reputation: 1059

you could set enableIvy to false in your tsconfig.app.json, that should fix your problem

"enableIvy": false

Upvotes: 2

Related Questions