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.

Angular6 - ng build / serve --prod - Error during template compile of 'AppModule'

See original GitHub issue

I have this problem when I’m building or seving an Angular6 application for PROD with ng serve --prod or ng build --prod

ERROR in app/app.module.ts(84,47): Error during template compile of 'AppModule'
  Complex function calls are not supported. in 'intersectionObserverPreset'
    'intersectionObserverPreset' references 'intersectionObserverPreset'
      'intersectionObserverPreset' references 'intersectionObserverPreset'
        'intersectionObserverPreset' contains the error.

This is what I have in the line app/app.module.ts(84,47)

import { LazyLoadImageModule, intersectionObserverPreset } from 'ng-lazyload-image';
@NgModule({
    imports: [
             ...,
/*84 -->*/ LazyLoadImageModule.forRoot({ preset: intersectionObserverPreset }) /*<-- 84*/
    ],
    declarations:  [...],
    entryComponents [...],
    providers: [...],
    bootstrap: [...]
})

Versions:

angular: 6.1.0
ng-lazyload-image: 5.0.0
npm: 5.6.0
node: 8.11.4
typescript: 2.7.2

It seems to have something to do with AOT but I can’t find a way to fix it. This error does not occur when normally running the commands ng build or ng serve

I appreciate any help

Thanks!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:19 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
johnqiuwancommented, Feb 2, 2019

I have the exactly same issue, and I am using angular version 7. It wokrs on ‘ng serve’ but not ‘ng build --prod --aot’

is there any solution for the issue?

0reactions
maxakashcommented, Apr 3, 2019

Updating to ng-lazyload-image@5.1.2 and angular 7 solved the issue. Thanks for resolving .

Read more comments on GitHub >

github_iconTop Results From Across the Web

ERROR in Error during template compile of 'AppModule'
Trying to build an Angular 6 app. I am getting the following error when using --prod. ERROR in Error during template compile of...
Read more >
ERROR in Error during template compile of 'AppModule'
I had the same error when attempting to use a UrlMatcher when AOT was enabled for the production build. const adminRoutes: Routes =...
Read more >
Ahead-of-time (AOT) compilation - Angular
When you run the ng build (build only) or ng serve (build and serve locally) CLI commands, the type of compilation (JIT or...
Read more >
Leveling up our developer experience | Accelerating Angular ...
Compile -time errors are a positive side effect of Angular using an AOT compiler. However, some of the build errors have needed additional...
Read more >
Angular App Shell - Boost Application Startup Performance
And this will create a new folder named my-app-shell with a new ... ng serve --prod ... What does the ng generate app-shell...
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