Skip to content

Need to run "ng build | serve | test" twice to finish command without errors #19395

Closed
@madoar

Description

@madoar

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • extract-i18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Yes, if I remember correctly with Angular 8 this error was not present or at least I didn't stumble across it. (I'm not entirely sure but it is also possible that it worked as well with Angular 9)

Description

I'm the author of the angular library angular-archwizard which I build with angular-cliandng-packagr. In addition to the main repository that contains the sourcecode for the library I have a second repository called angular-archwizard-demothat contains an angular project with a number of buildable examples usingangular-archwizard`.

I also use the angular-archwizard-demo project for manual testing to ensure that any changes that I make on the sourcecode of the library continues to function correctly visually. For this purpose I'm added a custom "preinstall" script to my travis setup that first clones the angular-archwizard repository, builds it locally and then includes it into the angular-archwizard-demo project using npm install --save ../angular-archwizard/dist.

For a while now I discovered that I need to run certain ng commands twice to get a "successful" result. These commands are ng build, ng serve and ng test. The first time I execute ng build or ng serve I receive an erroneous build, that leads to the following error message in the console of Chromium:

Uncaught Error: Type ArchwizardModule does not have 'ɵmod' property.
    at getNgModuleDef (core.js:1839)
    at recurse (core.js:24878)
    at recurse (core.js:24889)
    at recurse (core.js:24889)
    at registerNgModuleType (core.js:24874)
    at new NgModuleFactory$1 (core.js:24988)
    at compileNgModuleFactory__POST_R3__ (core.js:28544)
    at PlatformRef.bootstrapModule (core.js:28782)
    at Module.zUnb (main.ts:11)
    at __webpack_require__ (bootstrap:79)

The second time I get a functional build, that works as expected.

When running ng test for the first time it fails with the errors as shown in the following Travis CI job. When executing the tests for the second time they finish successfully.

In my opinion it is also important to note that I build the library itself (angular-archwizard) with Ivy disabled and the demo project (angular-archwizard-demo) with Ivy enabled. If I change this to either building both projects with Ivy enabled or disabled the commands work as expected on the first try. Therefore my guess is that the interoperability of Ivy projects with non-Ivy projects is somehow erroneous (or my config is)

🔬 Minimal Reproduction

Tasks to build the library

  1. clone angular-archwizard (https://github.com/madoar/angular-archwizard)
  2. install all dependencies (npm install)
  3. build the library (npm run build)

Tasks to build the demo and run its tests

  1. clone angular-archwizard-demo (https://github.com/madoar/angular-archwizard-demo)
  2. switch to the Angular (11) update branch (git checkout enhancement-update-dependencies)
  3. optional step: delete package-lock.json file
  4. install your local "development" version of angular-archwizard (npm install --save ../angular-archwizard/dist)
  5. install all remaining dependencies (npm install)
  6. run tests (npm test)

🔥 Exception or Error

🌍 Your Environment



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

Angular CLI: 11.0.1
Node: 12.12.0
OS: linux x64

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

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1100.1
@angular-devkit/build-angular   0.1100.1
@angular-devkit/core            11.0.1
@angular-devkit/schematics      11.0.1
@angular/cli                    11.0.1
@schematics/angular             11.0.1
@schematics/update              0.1100.1
rxjs                            6.6.3
typescript                      4.0.5

Anything else relevant?
Off-topic: If you execute the above commands with node 15 you get an error message because of an incompatible karma version (5.2.x is larger than 5.1.x)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions