Abx
Abx

Reputation: 2882

Ng serve Error after updating to Angular 11

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.

Upvotes: 1

Views: 2154

Answers (2)

Saeed Falsafin
Saeed Falsafin

Reputation: 558

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 [email protected]

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.

Upvotes: 3

Abx
Abx

Reputation: 2882

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

Upvotes: 0

Related Questions