Search code examples
angularangular-materialionic5

Angular JIT compilation failed: '@angular/compiler' not loaded


Angular JIT compilation failed: '@angular/compiler' not loaded!

  • JIT compilation is discouraged for production use-cases! Consider AOT mode instead.
  • Did you bootstrap using '@angular/platform-browser-dynamic' or '@angular/platform-server'?
  • Alternatively provide the compiler with 'import "@angular/compiler";' before bootstrapping.

Getting this error when build production build in dev mode not getting any error


Solution

  • Late to answer this, but since this came up first on Google Search results, my fix could be helpful to someone else (might even help me in future ;) ).

    If your app is using HttpClient for making any HTTP calls, probably you did similar mistake as me and imported HttpClient instead of HttpClientModule & ended up with the error message from question.

    Simply replace the HttpClient with HttpClientModule in your imports array in @NgModule & add import the class.

    import { HttpClientModule } from '@angular/common/http';
    
    @NgModule({
        declarations: [AppComponent, ProductListComponent],
        imports: [BrowserModule, FormsModule, HttpClientModule],
        bootstrap: [AppComponent],
    })