1

I updated my Angular app to 11

Package                            Version
----------------------------------------------------
@angular-devkit/architect          0.1102.10
@angular-devkit/build-angular      0.1102.10
@angular-devkit/core               11.2.10
@angular-devkit/schematics         11.2.10
@angular/cdk                       11.2.10
@angular/cli                       11.2.10
@angular/material                  11.2.10
@angular/material-moment-adapter   11.2.10
@schematics/angular                11.2.10
@schematics/update                 0.1102.10
rxjs                               6.6.7
typescript                         4.2.4

But, once I try to do a ng serve I get the below error

Error: ./src/main.ts
Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
TypeError: angularCompiler.getNextProgram is not a function
    at angularCompiler.analyzeAsync.then

I tried the suggestion mention here Errors after npm audit fix angular 10.0.1 but didnt help. Wondering if I am missing something here.

Abx
  • 2,852
  • 4
  • 30
  • 50
  • 1
    Did you run `ngcc` on your node_modules after installation? – 31piy Apr 23 '21 at 08:24
  • @31piy I tried "ngcc": "ngcc --properties es2015 browser main module --async false --first-only", "postinstall": "npm run ngcc" but it didnt work aswell – Abx Apr 23 '21 at 09:12

2 Answers2

3

I faced exactly the same problem but I wouldn't disable ivy. If @angular/compiler and @angular/compiler-cli has been updated to the version 12.0.0-rc.0, You need to downgrade them to the latest stable version 11, Also typescript to the version 4.1.5.

This worked for me.

npm install @angular/compiler@^11.2.12 @angular/compiler-cli@^11.2.12 typescript@4.1.5

17 May 2021 Update:

The v12 is stable and has been officially released by Angular on 13 May 2021, So you can use the official guide to upgrade to v12 and this error will be fixed. Or simply you can use this command to upgrade to v12:

ng update @angular/core@12 @angular/cli@12

and in case of using angular material, you can use this command to update it too:

ng update @angular/material

The detailed information can be found in the provided link.

Saeed Falsafin
  • 556
  • 6
  • 15
0

It seems that the issue was with ivy .It works for now if I disable it "enableIvy": false in angularCompilerOptions within tsconfig.app.json

Abx
  • 2,852
  • 4
  • 30
  • 50