Skip to content

ng add @angular/pwa - Cannot read property 'length' of undefined #16226

Closed
@GeorgiyZhuravlev

Description

@GeorgiyZhuravlev

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • xi18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

I don't know

Description

If your src/app/app.module.ts imports environment with the alias like this:

import {environment as env} from '../environments/environment';

ng add @angular/pwa fails with Cannot read property 'length' of undefined

🔬 Minimal Reproduction

  1. create empty project with angular-cli, eg:
    ng new some-app --prefix=some
  2. add this line to src/app/app.module.ts
    import {environment as env} from '../environments/environment';
  3. try to add @angular/pwa to project
    ng add @angular/pwa --project some-app

🔥 Exception or Error


ng add @angular/pwa --project some-app

Installing packages for tooling via npm.
+ @angular/pwa@0.803.19
added 5 packages from 2 contributors and audited 18936 packages in 6.047s
found 0 vulnerabilities

Installed packages for tooling via npm.
Cannot read property 'length' of undefined

🌍 Your Environment


Angular CLI: 8.3.19
Node: 10.16.3
OS: darwin x64
Angular: 8.2.14
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.803.19
@angular-devkit/build-angular     0.803.19
@angular-devkit/build-optimizer   0.803.19
@angular-devkit/build-webpack     0.803.19
@angular-devkit/core              8.3.19
@angular-devkit/schematics        8.3.19
@angular/cli                      8.3.19
@angular/pwa                      0.803.19
@ngtools/webpack                  8.3.19
@schematics/angular               8.3.19
@schematics/update                0.803.19
rxjs                              6.4.0
typescript                        3.5.3
webpack                           4.39.2

Anything else relevant?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions