Search code examples
angularprogressive-web-apps

Angular PWA: An unhandled exception occurred: Cannot find module '@schematics/angular/utility'


I've been trying to put the following command:

ng add @angular/pwa

However, I got this error:

An unhandled exception occurred: Cannot find module '@schematics/angular/utility'

I tried installing @schematics using NPM, but it doesn't work and I can't find further information about it.


Solution

  • I found an answer in a Github issue. My environment version is:

    Angular CLI: 13.3.7
    Node: 14.17.4
    Package Manager: npm 8.5.5
    OS: linux x64
    
    Angular: 13.3.11
    ... animations, common, compiler, compiler-cli, core, forms
    ... platform-browser, platform-browser-dynamic, platform-server
    ... router, service-worker
    
    Package                         Version
    ---------------------------------------------------------
    @angular-devkit/architect       0.1303.7
    @angular-devkit/build-angular   13.3.7
    @angular-devkit/core            14.0.1
    @angular-devkit/schematics      14.0.1
    @angular/cdk                    13.3.9
    @angular/cli                    13.3.7
    @angular/material               13.3.9
    @angular/pwa                    14.0.1
    @nguniversal/builders           13.1.1
    @nguniversal/express-engine     13.1.1
    @schematics/angular             9.1.13
    rxjs                            7.5.5
    typescript                      4.6.4
    

    In this case, we need to use this specific command:

    ng add @angular/pwa@13
    

    The Github post is https://github.com/angular/angular-cli/issues/23343