TypeError中的错误:无法读取未定义的属性“标志" [英] ERROR in TypeError: Cannot read property 'flags' of undefined
问题描述
当我尝试在最近创建的Angular项目上运行ng serve
时遇到问题.
我使用的版本是9.1.4,在具有较旧Angular版本的项目中不会发生此错误.
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
执行ng serve
或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:\Cursos\Angular\ang-hello-world\node_modules\typescript\lib\typescript.js:36513:37)
at checkAliasSymbol (C:\Cursos\Angular\ang-hello-world\node_modules\typescript\lib\typescript.js:64502:26)
at checkImportBinding (C:\Cursos\Angular\ang-hello-world\node_modules\typescript\lib\typescript.js:64534:13)
at checkImportDeclaration (C:\Cursos\Angular\ang-hello-world\node_modules\typescript\lib\typescript.js:64552:29)
at checkSourceElementWorker (C:\Cursos\Angular\ang-hello-world\node_modules\typescript\lib\typescript.js:64961:28)
at checkSourceElement (C:\Cursos\Angular\ang-hello-world\node_modules\typescript\lib\typescript.js:64800:17)
at Object.forEach (C:\Cursos\Angular\ang-hello-world\node_modules\typescript\lib\typescript.js:317:30)
at checkSourceFileWorker (C:\Cursos\Angular\ang-hello-world\node_modules\typescript\lib\typescript.js:65123:20)
at checkSourceFile (C:\Cursos\Angular\ang-hello-world\node_modules\typescript\lib\typescript.js:65091:13)
at getDiagnosticsWorker (C:\Cursos\Angular\ang-hello-world\node_modules\typescript\lib\typescript.js:65179:17)
at Object.getDiagnostics (C:\Cursos\Angular\ang-hello-world\node_modules\typescript\lib\typescript.js:65165:24)
at C:\Cursos\Angular\ang-hello-world\node_modules\typescript\lib\typescript.js:98703:85
at runWithCancellationToken (C:\Cursos\Angular\ang-hello-world\node_modules\typescript\lib\typescript.js:98665:24)
at getBindAndCheckDiagnosticsForFileNoCache (C:\Cursos\Angular\ang-hello-world\node_modules\typescript\lib\typescript.js:98691:20)
at getAndCacheDiagnostics (C:\Cursos\Angular\ang-hello-world\node_modules\typescript\lib\typescript.js:98956:26)
at getBindAndCheckDiagnosticsForFile (C:\Cursos\Angular\ang-hello-world\node_modules\typescript\lib\typescript.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 /
推荐答案
编辑
如果使用angular 9.1.6,现在应该可以了
If you use angular 9.1.6 it should be fine now
npm update @angular/cli @angular/core
原始帖子
在Angular 9.1.5中出现了问题-如果运行以下命令,它将可以正常工作:
Something is broken in Angular 9.1.5 - if you run the following it should work:
npm install @angular/core@9.1.4 @angular/animations@9.1.4 @angular/common@9.1.4 @angular/forms@9.1.4 @angular/platform-browser@9.1.4 @angular/router@9.1.4 @angular/platform-browser-dynamic@9.1.4 @angular/compiler@9.1.4 @angular/compiler-cli@9.1.4 @angular/language-service@9.1.4
ng build
仅花费约4-5个小时自己修复它...
Just spent about 4-5 hours trying to fix it myself...
问题似乎源于将Angular CLI 9.1.4与Angular 9.1.5一起使用(很可能是编译器
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
如果得到:
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
然后,您将需要执行上面列出的npm安装
Then you will need to follow the npm installs i listed above
这篇关于TypeError中的错误:无法读取未定义的属性“标志"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!