Angular-cli: Build --watch failing on rebuild

Created on 3 Nov 2017  ·  16Comments  ·  Source: angular/angular-cli

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

Angular CLI: 1.5.0
Node: 8.1.0
OS: darwin x64
Angular: 5.0.0
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cdk: 2.0.0-beta.12
@angular/cli: 1.5.0
@angular/flex-layout: 2.0.0-beta.10
@angular/material: 2.0.0-beta.12
@angular-devkit/build-optimizer: 0.0.32
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.35
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.0
@schematics/angular: 0.1.0
typescript: 2.6.1
webpack: 3.8.1

Repro steps.

  1. Run in terminal: ./node_modules/.bin/ng build --aot --env=dev --watch
  2. -> The build is successful
  3. Add a new line to any source file
  4. The build will throw an error:
ERROR in Error: Debug Failure. False expression: Host should not return a redirect source file from `getSourceFile`
    at tryReuseStructureFromOldProgram (/node_modules/typescript/lib/typescript.js:72100:26)
    at Object.createProgram (/node_modules/typescript/lib/typescript.js:71808:34)
    at AngularCompilerProgram._createProgramWithBasicStubs (/node_modules/@angular/compiler-cli/src/transformers/program.js:431:29)
    at /node_modules/@angular/compiler-cli/src/transformers/program.js:144:28
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:169:7)

The log given by the failure.

ERROR in Error: Debug Failure. False expression: Host should not return a redirect source file from `getSourceFile`
    at tryReuseStructureFromOldProgram (/node_modules/typescript/lib/typescript.js:72100:26)
    at Object.createProgram (/node_modules/typescript/lib/typescript.js:71808:34)
    at AngularCompilerProgram._createProgramWithBasicStubs (/node_modules/@angular/compiler-cli/src/transformers/program.js:431:29)
    at /node_modules/@angular/compiler-cli/src/transformers/program.js:144:28
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:169:7)

Desired functionality.

Adding a new line shouldn't break the build

Most helpful comment

The same error still shows up for current angular 5.2.x and @ngtools/webpack 1.10.1 if I use a TS version != 2.4.2. As Angular 5.2 officially supports TS 2.6 this is now a real bug, please reopen.

All 16 comments

Hi Guys,

I also get this issue on change of source code like fixing an import reference.

I am using ng serve --aot

Regards,
Tarek

I reverted my typescript version to “<2.5.0” and it’s working fine.

The current version of typescript supported is 2.4.2, please use that version for now. Support for later versions of TypeScript are being looked into.

When using typescript 2.4.2 with ng build -prod, I get this error.
(Which the fix here says to upgrade typescript to 2.6.1.)

ERROR in ./node_modules/rxjs/_esm5/observable/BoundNodeCallbackObservable.js
Module build failed: TypeError: Cannot read property 'type' of undefined at Object.getEffectiveTypeAnnotationNode (node_modules/typescript/lib/typescript.js:9341:17).

When using typescript 2.6.1 with ng serve --aot, I get the above error when incrementally saving a .html or .ts file
(Which the fix above says to downgrade to typescript 2.4.2...)

ERROR in Error: Debug Failure. False expression: Host should not return a redirect source file from `getSourceFile`
    at tryReuseStructureFromOldProgram (.../node_modules/typescript/lib/typescript.js:72100:26)
    at Object.createProgram (.../node_modules/typescript/lib/typescript.js:71808:34)
    at AngularCompilerProgram._updateProgramWithTypeCheckStubs (.../node_modules/@angular/compiler-cli/src/transformers/program.js:461:30)
    at .../node_modules/@angular/compiler-cli/src/transformers/program.js:149:23
    at process._tickCallback (internal/process/next_tick.js:103:7)

So I am in a catch 22, where I need typescript 2.4.2 for ng serve --aot and typescript 2.6.1 for ng build --prod.

See also #8434. Typescript@next (currently 2.7.0-dev.20171216) is needed to fix other issues as well.

The same error still shows up for current angular 5.2.x and @ngtools/webpack 1.10.1 if I use a TS version != 2.4.2. As Angular 5.2 officially supports TS 2.6 this is now a real bug, please reopen.

I'm having the same problem after moving an imported .ts file outside the app structure (it acts as a shared module). This works in the first build and fails after a live rebuild.

Using a non-aot developer build seems to work just fine. I can reproduce the issue every time, here's the log:

ERROR in Error: Debug Failure. False expression: Host should not return a redirect source file from `getSourceFile`
    at tryReuseStructureFromOldProgram (/.../node_modules/typescript/lib/typescript.js:74285:26)
    at Object.createProgram (/.../node_modules/typescript/lib/typescript.js:73988:34)
    at AngularCompilerProgram._updateProgramWithTypeCheckStubs (/.../node_modules/@angular/compiler-cli/src/transformers/program.js:460:30)
    at /.../node_modules/@angular/compiler-cli/src/transformers/program.js:148:23
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:118:7)

This is not critical, but a major nuisance. Any help?

Same problem here using Typescript 2.6.2, webpack 3.10, Angular 5.2.x with ngtools/webpack 1.10.2 (compiler-cli 5.2).

Same problem here using Typescript 2.7.2, webpack 3.11.0, Angular 5.2.9

ERROR in Error: Debug Failure. False expression: Host should not return a redirect source file fromgetSourceFile at tryReuseStructureFromOldProgram (/node_modules/typescript/lib/typescript.js:74285:26) at Object.createProgram (/node_modules/typescript/lib/typescript.js:73988:34) at AngularCompilerProgram._updateProgramWithTypeCheckStubs (/node_modules/@angular/compiler-cli/src/transformers/program.js:460:30) at /node_modules/@angular/compiler-cli/src/transformers/program.js:148:23 at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7)

@Brocco I understand the issue was closed initially due to TypeScript version mismatch, but it seems like the issue can still be reproduced with 6.0.8, easily. Should this issue be reopened?

Angular CLI: 6.0.8
Node: 8.11.2
OS: darwin x64
Angular: 6.0.5
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router, upgrade

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.8
@angular-devkit/build-angular     0.6.8
@angular-devkit/build-optimizer   0.6.8
@angular-devkit/core              0.6.8
@angular-devkit/schematics        0.6.8
@angular/cli                      6.0.8
@ngtools/webpack                  6.0.8
@schematics/angular               0.6.8
@schematics/update                0.6.8
rxjs                              6.2.1
typescript                        2.7.2
webpack                           4.8.3

I just ran into this as well on 6.1.0-rc.0

Angular CLI: 6.1.0-rc.0
Node: 8.9.1
OS: win32 x64
Angular: 6.0.6
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.7.0-rc.0
@angular-devkit/build-angular     0.7.0-rc.0
@angular-devkit/build-optimizer   0.7.0-rc.0
@angular-devkit/core              0.7.0-rc.0
@angular-devkit/schematics        0.7.0-rc.0
@angular/cli                      6.1.0-rc.0
@schematics/angular               0.7.0-rc.0
@schematics/update                0.7.0-rc.0
rxjs                              6.2.0
typescript                        2.7.2
webpack                           4.8.1

Can confirm this is still a thing with Angular 6.0.9 and CLI 6.0.8, issue should be reopen

I've got same error on production build

When I run project with JIT compilation - cli can build, and the rebuild on changes. When I compile with AOT - first build succeed, but on change cli can't rebuild, and displays

ERROR in Debug Failure. False expression: Host should not return a redirect source file from `getSourceFile`
ℹ 「wdm」: Failed to compile.
Angular CLI: 6.2.1
Node: 10.1.0
OS: darwin x64
Angular: 6.1.7
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.7.5
@angular-devkit/build-angular     0.7.5
@angular-devkit/build-optimizer   0.7.5
@angular-devkit/build-webpack     0.7.5
@angular-devkit/core              0.7.5
@angular-devkit/schematics        0.8.1
@angular/cli                      6.2.1
@ngtools/webpack                  6.1.5
@schematics/angular               0.8.1
@schematics/update                0.8.1
rxjs                              6.3.2
typescript                        2.9.2
webpack                           4.9.2

Guys, this ticket is closed and dead. The current ticket tracking the problem is https://github.com/angular/angular/issues/22524

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gotschmarcel picture gotschmarcel  ·  3Comments

rajjejosefsson picture rajjejosefsson  ·  3Comments

IngvarKofoed picture IngvarKofoed  ·  3Comments

MateenKadwaikar picture MateenKadwaikar  ·  3Comments

JanStureNielsen picture JanStureNielsen  ·  3Comments