angular-cli: AOT error this.host.isSourceFile is not a function

Please provide us with the following information:

OS?

Ubuntu 16.04 Linux Mint 18.1

Versions.

Please run ng --version. If there’s nothing outputted, please run in a Terminal: node --version and paste the result here: angular-cli: 1.0.0-beta.24 node: 7.2.1 os: linux x64 @angular/common: 2.4.0 @angular/compiler: 2.4.0 @angular/core: 2.4.0 @angular/forms: 2.4.0 @angular/http: 2.4.0 @angular/platform-browser: 2.4.0 @angular/platform-browser-dynamic: 2.4.0 @angular/router: 3.3.1 @angular/compiler-cli: 2.3.1

Repro steps.

Was this an app that wasn’t created using the CLI? What change did you do on your code? etc.

ng build -prod --aot
ng build --aot

The log given by the failure.

Normally this include a stack trace and some more information.

Time: 7649ms
chunk    {0} main.117bc7f89a641eb460be.bundle.js, main.117bc7f89a641eb460be.bundle.map (main) 1.15 kB {2} [initial] [rendered]
chunk    {1} styles.0d70df7dda13fb01d123.bundle.css, styles.0d70df7dda13fb01d123.bundle.map, styles.0d70df7dda13fb01d123.bundle.map (styles) 1.69 kB {3} [initial] [rendered]
chunk    {2} vendor.078bc367dec701b1150c.bundle.js, vendor.078bc367dec701b1150c.bundle.map (vendor) 1.06 MB [initial] [rendered]
chunk    {3} inline.4357686ae3fba1b6d5e7.bundle.js, inline.4357686ae3fba1b6d5e7.bundle.map (inline) 0 bytes [entry] [rendered]

ERROR in this.host.isSourceFile is not a function

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/home/alex/Dev/ng2/learn/playng/src'
 @ ./src/main.ts 4:0-74
 @ multi main

ERROR in ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js
Module not found: Error: Can't resolve '/home/alex/Dev/ng2/learn/playng/src/$$_gendir' in '/home/alex/Dev/ng2/learn/playng/node_modules/@angular/core/src/linker'
 @ ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js 69:15-36 85:15-102
 @ ./~/@angular/core/src/linker.js
 @ ./~/@angular/core/src/core.js
 @ ./~/@angular/core/index.js
 @ ./src/main.ts
 @ multi main

Mention any other details that might be useful.

repo link: https://github.com/Codenator81/tour-of-heroes-angularfire2 live site: https://n2play-ee2bb.firebaseapp.com/ it worked without --aot parametr


Thanks! We’ll be in touch soon.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 2
  • Comments: 16 (3 by maintainers)

Most upvoted comments

Got the same error compiling aot, and im NOT using angularfire2 - not that i know of anyway.

Any pointers to fix this is highly appreciated.

Thanks for reporting this issue. This issue is now obsolete due to changes in the recent releases. Please update to the most recent Angular CLI version.

If the problem persists after upgrading, please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior.

Updated @angular/compiler-cli: 2.3.1 to 2.4.0 got errors

ERROR in Can't resolve all parameters for FirebaseSdkAuthBackend in /home/alex/Dev/ng2/learn/playng/node_modules/angularfire2/auth/firebase_sdk_auth_backend.d.ts: ([object Object], ?).

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/home/alex/Dev/ng2/learn/playng/src'
 @ ./src/main.ts 4:0-74
 @ multi main

ERROR in ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js
Module not found: Error: Can't resolve '/home/alex/Dev/ng2/learn/playng/src/$$_gendir' in '/home/alex/Dev/ng2/learn/playng/node_modules/@angular/core/src/linker'
 @ ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js 69:15-36 85:15-102
 @ ./~/@angular/core/src/linker.js
 @ ./~/@angular/core/src/core.js
 @ ./~/@angular/core/index.js
 @ ./src/main.ts
 @ multi main

without aot all good

Why issue is closed? Nothing works!

For my case:

  • Doing JIT build seems fine (either using ngtools/webpack with codegeneration disabled or using template+router loaders) and app running well
  • Doing AOT build fails
    • Successful after upgrade angularfire2 to beta.7-pre, look https://github.com/angular/angularfire2/issues/728
    • but only the build succeed, the app is throwing error on runtime, looks like AOT did something to my constant exports that my config values are undefined when accessed by angularfire2

@antonybudianto mentioned in https://github.com/angular/angular-cli/issues/3761 that this is likely related to angularfire2.