question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ng build --aot fails

See original GitHub issue

Please provide us with the following information:

OS?

Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)

OS X El Capitan

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.25.5 node: 6.7.0 os: darwin x64 @angular/common: 2.4.3 @angular/compiler: 2.4.3 @angular/core: 2.4.3 @angular/forms: 2.4.3 @angular/http: 2.4.3 @angular/platform-browser: 2.4.3 @angular/platform-browser-dynamic: 2.4.3 @angular/router: 3.4.3 @angular/material: 2.0.0-beta.1

Repro steps.

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

If I run ng build --aot it throws an error after it logs the bundles that were created.

The log given by the failure.

Normally this include a stack trace and some more information.

Hash: f623b656056e9a59a302                                                               
Time: 14288ms
chunk    {0} scripts.b070e2134bb20fc4e5f5.bundle.js (scripts) 730 kB {4} [initial] [rendered]
chunk    {1} styles.fe1bc11c112063cca818.bundle.css (styles) 21.9 kB {4} [initial] [rendered]
chunk    {2} main.3269aa95e662115bc916.bundle.js (main) 1.97 kB {3} [initial] [rendered]
chunk    {3} vendor.9340472a0450b55ed1fe.bundle.js (vendor) 1.08 MB [initial] [rendered]
chunk    {4} inline.a6aa1cbd561bcc42ae6c.bundle.js (inline) 0 bytes [entry] [rendered]

ERROR in providers.forEach is not a function

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/Users/rolandjitsu/Projects/infarm/dashboard/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 '/Users/rolandjitsu/Projects/infarm/dashboard/src/$$_gendir' in '/Users/rolandjitsu/Projects/infarm/dashboard/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.


Thanks! We’ll be in touch soon.

Issue Analytics

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

github_iconTop GitHub Comments

5reactions
Splaktarcommented, Jan 18, 2017

I get the same thing but without the ERROR in providers.forEach is not a function and no other message in its place.

1reaction
rolandjitsucommented, Feb 28, 2017

I found the issue. It seems like AOT does not like:

const providers = [];

if (someCondition) {
    providers.push({ ...some object });
}

@NgModule({
    providers
})
export class TestModule {}

But it works with:

const providers = [];

if (someCondition) {
    providers.push({ ...some object });
}

@NgModule({
    providers: [
        ...providers
    ]
})
export class TestModule {}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Build got failed while using 'ng build ---aot' #14717 - GitHub
it throws a same error: Screenshot (271). Working fine. When using "ng serve" with target es2015 and es6. And all commands are working...
Read more >
Angular CLI - AOT error during ng build - Stack Overflow
I created a application using Angular CLI and it works fine with the JIT compilation. I felt i need to make my application...
Read more >
ng build fails if AOT is enabled (Angular 11) - DayPilot Forums
This likely means that the library (daypilot-pro-angular) which declares DayPilotModule has not been processed correctly by ngcc, or is not compatible with ...
Read more >
Angular CLI ng build fails - Visual Studio Feedback
Angular CLI ng build fails ... I have tried turning off the AOT but still no go. ... Failed at the ba-web-app@0.0.0 build...
Read more >
Angular: Writing AoT-friendly applications | by David - Medium
However, with AoT compilation ( ng build --prod ), we encounter several errors. ... This causes AoT compilation to fail and has two...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found