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

Dung Do Tien Nov 12 2020 114

After create a website in angular 9 but I got a problem. In some page I got the error Uncaught Error: Angular JIT compilation failed: '@angular/compiler' not loaded! but some pages are not thrown.

ERROR Error: Uncaught (in promise): Error: 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.
Error: 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.

And below is my environment of the project:

Angular CLI: 9.0.3
Node: 10.16.0
OS: win32 x64

Angular: 9.0.2
... animations, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.900.3
@angular-devkit/build-angular     0.900.3
@angular-devkit/build-optimizer   0.900.3
@angular-devkit/build-webpack     0.900.3
@angular-devkit/core              9.0.3
@angular-devkit/schematics        9.0.3
@angular/cdk                      8.2.3
@angular/cli                      9.0.3
@angular/material                 8.2.3
@ngtools/webpack                  9.0.3
@schematics/angular               9.0.3
@schematics/update                0.900.3
rxjs                              6.5.4
typescript                        3.7.5
webpack                           4.41.2

I don't why, please tell me if you have any solution.

Have 2 answer(s) found.
  • You can try the solution below:

    1. Set aot= true in angular.json file.

    2. Add "postinstall": "ngcc --properties es5 browser module main --first-only" in package.json file.

    3. Delete node_modules folder and package-lock.json file and install again by run command npm install.

     

    I hope it resolves the issue for you.

    Sandeep Kumar Nov 12 2020
  • Update all the dependencies in your node_modules folder (This issue can be generated due to incompatibility of some dependency versions) run npm update in the project terminal to update all dependencies.

    Marry Christ Nov 12 2020
Leave An Answer
* NOTE: You need Login before leave an answer

* Type maximum 2000 characters.

* All comments have to wait approved before display.

* Please polite comment and respect questions and answers of others.

Popular Tips