Angular 9 - build in production mode prints error messages to log

Viewed 3493

After upgrading to angular 9, when I build my project in production mode I get this output-

[ERROR] 
[ERROR] Compiling @angular/core : module as esm5
[ERROR] 
[ERROR] Compiling @angular/common : module as esm5
[ERROR] 
[ERROR] Compiling @angular/platform-browser : module as esm5
[ERROR] 
[ERROR] Compiling @angular/platform-browser-dynamic : module as esm5
[ERROR] 
[ERROR] Compiling @angular/common/http : module as esm5
[ERROR] 

and so on..

Any reason why?

2 Answers

With angular 9 and ivy, you need a postinstall script to manage compatibility with libraries ( node_modules) Add in your package.json

{
  "scripts": {
    "postinstall": "ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points"
  }
}

and run npm install

You can look at : https://angular.io/guide/ivy

And make sure you have this compiler options in your tsconfig :

 "compilerOptions": {
    "target": "es2015",
    "module": "esnext",
    "moduleResolution": "node",
    "lib": [
      "es2018",
      "dom"
    ]
}

Update your TS version. Try 3.7.0

npm install typescript@3.7.0

Related