Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
740 views
in Technique[技术] by (71.8m points)

angular - ERROR in TypeError: Cannot read property 'flags' of undefined

I have a problem when I try to run ng serve on a recently created Angular project. The version I'm using is 9.1.4, this error does not occur on a project with an older Angular version.

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.901.4
@angular-devkit/build-angular     0.901.4
@angular-devkit/build-optimizer   0.901.4
@angular-devkit/build-webpack     0.901.4
@angular-devkit/core              9.1.4
@angular-devkit/schematics        9.1.4
@angular/cli                      9.1.4
@ngtools/webpack                  9.1.4
@schematics/angular               9.1.4
@schematics/update                0.901.4
rxjs                              6.5.5
typescript                        3.8.3
webpack                           4.42.0

After executing ng serve or ng build:

chunk {main} main.js, main.js.map (main) 2 kB [initial] [rendered]<br>
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 679 bytes [initial] [rendered]<br>
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.15 kB [entry] [rendered]<br>
chunk {styles} styles.js, styles.js.map (styles) 12.4 kB [initial] [rendered]<br>
chunk {vendor} vendor.js, vendor.js.map (vendor) 339 kB [initial] [rendered]<br>
Date: 2020-05-08T02:06:46.145Z - Hash: 1a1b937f0ca2bb37634b - Time: 4087ms<br>

**ERROR in TypeError: Cannot read property 'flags' of undefined**
    at resolveAlias (C:CursosAngularang-hello-world
ode_modulesypescriptlibypescript.js:36513:37)
    at checkAliasSymbol (C:CursosAngularang-hello-world
ode_modulesypescriptlibypescript.js:64502:26)
    at checkImportBinding (C:CursosAngularang-hello-world
ode_modulesypescriptlibypescript.js:64534:13)
    at checkImportDeclaration (C:CursosAngularang-hello-world
ode_modulesypescriptlibypescript.js:64552:29)
    at checkSourceElementWorker (C:CursosAngularang-hello-world
ode_modulesypescriptlibypescript.js:64961:28)
    at checkSourceElement (C:CursosAngularang-hello-world
ode_modulesypescriptlibypescript.js:64800:17)
    at Object.forEach (C:CursosAngularang-hello-world
ode_modulesypescriptlibypescript.js:317:30)
    at checkSourceFileWorker (C:CursosAngularang-hello-world
ode_modulesypescriptlibypescript.js:65123:20)
    at checkSourceFile (C:CursosAngularang-hello-world
ode_modulesypescriptlibypescript.js:65091:13)
    at getDiagnosticsWorker (C:CursosAngularang-hello-world
ode_modulesypescriptlibypescript.js:65179:17)
    at Object.getDiagnostics (C:CursosAngularang-hello-world
ode_modulesypescriptlibypescript.js:65165:24)
    at C:CursosAngularang-hello-world
ode_modulesypescriptlibypescript.js:98703:85
    at runWithCancellationToken (C:CursosAngularang-hello-world
ode_modulesypescriptlibypescript.js:98665:24)
    at getBindAndCheckDiagnosticsForFileNoCache (C:CursosAngularang-hello-world
ode_modulesypescriptlibypescript.js:98691:20)
    at getAndCacheDiagnostics (C:CursosAngularang-hello-world
ode_modulesypescriptlibypescript.js:98956:26)
    at getBindAndCheckDiagnosticsForFile (C:CursosAngularang-hello-world
ode_modulesypescriptlibypescript.js:98688:20)

** **Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/** **

The result I get on my browser after running this project is:

Cannot GET /
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

edit

If you use angular 9.1.6 it should be fine now

npm update @angular/cli @angular/core

original post

Something is broken in Angular 9.1.5 - if you run the following it should work:

npm install @angular/[email protected] @angular/[email protected] @angular/[email protected] @angular/[email protected] @angular/[email protected] @angular/[email protected] @angular/[email protected] @angular/[email protected] @angular/[email protected] @angular/[email protected]

ng build

Just spent about 4-5 hours trying to fix it myself...

The issue seems to stem from using Angular CLI 9.1.4 with Angular 9.1.5 (most likely the compiler

You'll see the issue when you do

ng --version

if you get:

Angular CLI: 9.1.4
Node: 12.16.3
OS: win32 x64

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

Then you will need to follow the npm installs i listed above


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...