Приложение Fre sh Angular 9 с «ОШИБКА в Не удается прочитать свойство 'flags' of undefined» в Ma c в «ng build» - PullRequest
3 голосов
/ 06 марта 2020

Я создал новое приложение Angular 9 на своем Ma c, используя

ng new demo (no routing, CSS)
cd demo
ng build

, что не удается с

ERROR in Cannot read property 'flags' of undefined

"ng version" показывает

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 9.0.5
Node: 12.16.1
OS: darwin x64

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

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.900.5 (cli-only)
@angular-devkit/build-angular   0.900.5
@angular-devkit/core            9.0.5 (cli-only)
@angular-devkit/schematics      9.0.5 (cli-only)
@schematics/angular             9.0.5 (cli-only)
@schematics/update              0.900.5 (cli-only)
rxjs                            6.5.4
typescript                      3.7.5

Я отследил его до

TypeError: Cannot read property 'flags' of undefined
    at checkUnreachable (/Users/im/tmp/demo/node_modules/typescript/lib/typescript.js:31915:31)
    at bindChildrenWorker (/Users/im/tmp/demo/node_modules/typescript/lib/typescript.js:29665:17)
    at bindChildren (/Users/im/tmp/demo/node_modules/typescript/lib/typescript.js:29621:17)
    at bind (/Users/im/tmp/demo/node_modules/typescript/lib/typescript.js:31056:21)
    at bindSourceFile (/Users/im/tmp/demo/node_modules/typescript/lib/typescript.js:29211:17)
    at Object.bindSourceFile (/Users/im/tmp/demo/node_modules/typescript/lib/typescript.js:29148:9)
    at initializeTypeChecker (/Users/im/tmp/demo/node_modules/typescript/lib/typescript.js:64532:20)
    at Object.createTypeChecker (/Users/im/tmp/demo/node_modules/typescript/lib/typescript.js:33768:9)
    at Object.getTypeChecker (/Users/im/tmp/demo/node_modules/typescript/lib/typescript.js:95767:79)
    at NgCompiler.makeCompilation (/Users/im/tmp/demo/node_modules/@angular/compiler-cli/src/ngtsc/core/src/compiler.js:542:42)
    at NgCompiler.<anonymous> (/Users/im/tmp/demo/node_modules/@angular/compiler-cli/src/ngtsc/core/src/compiler.js:191:53)
    at step (/Users/im/tmp/demo/node_modules/tslib/tslib.js:139:27)
    at Object.next (/Users/im/tmp/demo/node_modules/tslib/tslib.js:120:57)
    at /Users/im/tmp/demo/node_modules/tslib/tslib.js:113:75
    at new Promise (<anonymous>)
    at Object.__awaiter (/Users/im/tmp/demo/node_modules/tslib/tslib.js:109:16)

Что, похоже, происходит при обработке файла: / Users / im / tmp / demo / node_modules / @ angular -devkit / build-angular / node_modules /typescript/lib/lib.es5.d.ts

Есть идеи, что здесь не так?

Некоторая информация о версии из-за пределов рабочего пространства

# npm version

{
  demo: '0.0.0',
  npm: '6.14.2',
  ares: '1.15.0',
  brotli: '1.0.7',
  cldr: '35.1',
  http_parser: '2.9.3',
  icu: '64.2',
  llhttp: '2.0.4',
  modules: '72',
  napi: '5',
  nghttp2: '1.40.0',
  node: '12.16.1',
  openssl: '1.1.1d',
  tz: '2019c',
  unicode: '12.1',
  uv: '1.34.0',
  v8: '7.8.279.23-node.31',
  zlib: '1.2.11'
}

# ng version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 9.0.5
Node: 12.16.1
OS: darwin x64

Angular: 
... 
Ivy Workspace: 

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.900.5
@angular-devkit/core         9.0.5
@angular-devkit/schematics   9.0.5
@schematics/angular          9.0.5
@schematics/update           0.900.5
rxjs                         6.5.3

# node -v
v12.16.1

1 Ответ

2 голосов
/ 07 марта 2020

Я нашел следующее решение:

После ng new demo я проверил файл package-lock.json и заметил, что @angular-devkit/build-angular и @angular-devkit/build-optimizer используют версию 3.6.4 машинописи.

После исправления файла package-lock.json и npm install они также используют машинописную версию 3.7.5, поскольку само приложение начало работать.

Другое решение - переход на пряжу, которая также исправила эту проблему прямо из начало:

ng new demo --packageManager=yarn
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...