angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

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

Open viperguynaz opened this issue 6 years ago β€’ 12 comments

🐞 Bug report

Command (mark with an x)

  • [X] new
  • [X] build
  • [X] serve

Is this a regression?

Yes, the previous version in which this bug was not present was: 9.1.3

Description

Fresh CLI generated project is throwing error below on build (ng serve)

πŸ”¬ Minimal Reproduction

ng new test-ts
cd test-ts
ng serve -o

πŸ”₯ Exception or Error

PS C:\github\test-ts> ng serve -o

chunk {main} main.js, main.js.map (main) 1.97 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 663 bytes [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.15 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 12.7 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 339 kB [initial] [rendered]
Date: 2020-05-07T23:40:34.042Z - Hash: 51e69acbabd203efe5f4 - Time: 8126ms

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

🌍 Your Environment


Angular CLI: 9.1.4
Node: 12.16.3
OS: win32 x64

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

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

Anything else relevant?

viperguynaz avatar May 07 '20 23:05 viperguynaz

Same thing happened to me, but upon some investigating it seemed to be something in Typescript. There are some issues for this error in several CLI tools.

https://github.com/microsoft/TypeScript/issues/38352 https://github.com/microsoft/TypeScript/issues/38147

This seems to be the main one: https://github.com/microsoft/TypeScript/issues/37165

Unfortunately I could not test with Typescript 4.0 because of the Angular compiler support.

stalinpimentel avatar May 08 '20 00:05 stalinpimentel

I ran into this issue as well with version 9.1.4 of the CLI. Version 9.1.3 also fails.

Just in case someone is curious, CLI version 10.0.0-next.3 compiled without errors. This isn't really a viable workaround for me as I need to run version 9.

Angular CLI: 10.0.0-next.3
Node: 12.16.3
OS: win32 x64

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

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.1000.0-next.3
@angular-devkit/build-angular     0.1000.0-next.3
@angular-devkit/build-optimizer   0.1000.0-next.3
@angular-devkit/build-webpack     0.1000.0-next.3
@angular-devkit/core              10.0.0-next.3
@angular-devkit/schematics        10.0.0-next.3
@angular/cli                      10.0.0-next.3
@ngtools/webpack                  10.0.0-next.3
@schematics/angular               10.0.0-next.3
@schematics/update                0.1000.0-next.3
rxjs                              6.5.5
typescript                        3.8.3
webpack                           4.43.0

kblooie avatar May 08 '20 01:05 kblooie

@kblooie I tested with Angular 9.1.0 using the same Typescript version (~3.8.3) and it built for me after creating a blank project.

stalinpimentel avatar May 08 '20 02:05 stalinpimentel

I have the same issue with Angular 9.1.4 and a blank new project.

timonohe avatar May 08 '20 07:05 timonohe

Hi all,

Can someone please push a reproduction to github and link it here?

We have several tests that cover the ng new scenario and none of them are failing. I also tried to reproduce this locally and I wasn't able.

Thanks.

alan-agius4 avatar May 08 '20 09:05 alan-agius4

`
Angular CLI: 9.1.4 Node: 12.16.1 OS: win32 x64

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

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`

I have the same error. I tried to create a new blank angular project, but when I tried to build I received that error.

After I tried this command to on my blank project: 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]

Now works.

doubler84 avatar May 08 '20 09:05 doubler84

How to reproduce with new 9.1.5 packages:

  • ng new projectName
  • ng serve

meriturva avatar May 08 '20 10:05 meriturva

same issue i had this morning when i installed a clean version of angular 9 globally

ERROR in TypeError: Cannot read property 'flags' of undefined at resolveAlias (D:\samples projects\angular9helloword\helloWorld\node_modules\typescript\lib\typescript.js:36513:37) at checkAliasSymbol (D:\samples projects\angular9helloword\helloWorld\node_modules\typescript\lib\typescript.js:64502:26) at checkImportBinding (D:\samples projects\angular9helloword\helloWorld\node_modules\typescript\lib\typescript.js:64534:13) at checkImportDeclaration (D:\samples projects\angular9helloword\helloWorld\node_modules\typescript\lib\typescript.js:64552:29) at checkSourceElementWorker (D:\samples projects\angular9helloword\helloWorld\node_modules\typescript\lib\typescript.js:64961:28)

"devDependencies": { "@angular-devkit/build-angular": "~0.901.4", "@angular/cli": "~9.1.4", "@angular/compiler-cli": "~9.1.4", "@angular/language-service": "~9.1.4", "@types/node": "^12.11.1", "@types/jasmine": "~3.5.0", "@types/jasminewd2": "~2.0.3", "codelyzer": "^5.1.2", "jasmine-core": "~3.5.0", "jasmine-spec-reporter": "~4.2.1", "karma": "~5.0.0", "karma-chrome-launcher": "~3.1.0", "karma-coverage-istanbul-reporter": "~2.1.0", "karma-jasmine": "~3.0.1", "karma-jasmine-html-reporter": "^1.4.2", "protractor": "~5.4.3", "ts-node": "~8.3.0", "tslint": "~6.1.0", "typescript": "~3.8.3" }

Angular CLI: 9.1.4 Node: v12.13.0 OS: windows 10 NPM : 6.12.0

i just did "ng new helloword" and after the project was created i tried "ng s -o" and threw the error above

please help

tnlthanzeel avatar May 08 '20 10:05 tnlthanzeel

I have same issue. ERROR in TypeError: Cannot read property 'flags' of undefined at resolveAlias (E:\Angular\node_modules\typescript\lib\typescript.js:36513:37) at checkAliasSymbol (E:\Angular\node_modules\typescript\lib\typescript.js:64502:26) at checkImportBinding (E:\Angular\node_modules\typescript\lib\typescript.js:64534:13) at checkImportDeclaration (E:\Angular\node_modules\typescript\lib\typescript.js:64552:29) at checkSourceElementWorker (E:\Angular\node_modules\typescript\lib\typescript.js:64961:28) at checkSourceElement (E:\Angular\node_modules\typescript\lib\typescript.js:64800:17) at Object.forEach (E:\Angular\node_modules\typescript\lib\typescript.js:317:30) at checkSourceFileWorker (E:\Angular\node_modules\typescript\lib\typescript.js:65123:20) at checkSourceFile (E:\Angular\node_modules\typescript\lib\typescript.js:65091:13) at getDiagnosticsWorker (E:\Angular\node_modules\typescript\lib\typescript.js:65179:17) at Object.getDiagnostics (E:\Angular\node_modules\typescript\lib\typescript.js:65165:24) at E:\Angular\node_modules\typescript\lib\typescript.js:98703:85 at runWithCancellationToken (E:\Angular\node_modules\typescript\lib\typescript.js:98665:24) at getBindAndCheckDiagnosticsForFileNoCache (E:\Angular\node_modules\typescript\lib\typescript.js:98691:20) at getAndCacheDiagnostics (E:\Angular\node_modules\typescript\lib\typescript.js:98956:26) at getBindAndCheckDiagnosticsForFile (E:\Angular\node_modules\typescript\lib\typescript.js:98688:20)

yangjunfocus avatar May 08 '20 10:05 yangjunfocus

Reproduction-Steps:

Angular CLI: 9.1.4 Node: 10.15.1 OS: win32 x64 Windows 10

Package Version

@angular-devkit/architect 0.901.4 @angular-devkit/core 9.1.4 @angular-devkit/schematics 9.1.4 @schematics/angular 9.1.4 @schematics/update 0.901.4 rxjs 6.5.4

  1. ng n helloworld
  2. ng serve

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

timonohe avatar May 08 '20 10:05 timonohe

This is a problem with ngcc in the Angular Framework not CLI. The issue (and resolution) is being tracked at https://github.com/angular/angular/issues/36992

petebacondarwin avatar May 08 '20 10:05 petebacondarwin

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.