【问题标题】:Angular9 : ngcc failing to runAngular9:ngcc 无法运行
【发布时间】:2020-04-23 22:02:47
【问题描述】:

我正在尝试从 Angular 8 更新到 9 (Ivy)。我正在尝试使用使用 Angular 8 编译的共享库。我添加了:

"postinstall":"ngcc"

在我的 package.json 中并尝试运行 ngcc。每次它给我以下错误:

TypeError: fn(...).finally is not a function
      at AsyncLocker.<anonymous> (...../node_modules/@angular/compiler-cli/ngcc/src/locking/async_locker.js:44:63)
        at step (.../node_modules/tslib/tslib.js:139:27)
        at Object.next (.../node_modules/tslib/tslib.js:120:57)
        at fulfilled (.../node_modules/tslib/tslib.js:110:62)
        at <anonymous>
        at process._tickCallback (internal/process/next_tick.js:189:7)
        at Function.Module.runMain (module.js:696:11)
        at startup (bootstrap_node.js:204:16)
        at bootstrap_node.js:625:3
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! project-ng@1.0.0 postinstall: `ngcc`
    npm ERR! Exit status 1
    npm ERR! 

我已尝试删除 node_modules,重新安装 npm 并尝试,但错误仍然存​​在。

这是我的 tsconfig.json

{
  "compilerOptions": {
    "target": "ESNext",
    "module": "ES2015",
    "lib": [
      "es2015",
      "dom"
    ],
    "moduleResolution": "node",
    "sourceMap": true,
    "declaration": true,
    "importHelpers": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false,
    "suppressImplicitAnyIndexErrors": true,
    "typeRoots": [
      "node_modules/@types"
    ]
  },
  "exclude": [
    "node_modules",
    "dist",
    "src/**/*.spec.ts",
    "src/**/*.e2e.ts",
    "**/*.ngfactory.ts"
  ],
  "angularCompilerOptions": {
    "entryModule": "./src/app/app.module#AppModule",
    "skipMetadataEmit": true
  }
}

欢迎对此提供任何帮助。 谢谢。

【问题讨论】:

  • 我做的另一件事是安装了最新的tslib。
  • ...为什么要运行 ngcc..?
  • 我正在尝试使用一个使用 Angular 8 编译的共享库。
  • Ivy 会自动为你做这件事.. 只需运行 ng serve..?
  • 它不是基于 CLI 的项目。

标签: angular angular9 angular-ivy


【解决方案1】:

在使用 npm install 从源代码管理重新安装 Angular 9 应用程序时,我收到了类似的错误消息。

在我的情况下,问题是由旧版本的 Node 引起的。

安装最新版本的 Node 解决了这个问题。

【讨论】:

  • 这是我可以尝试的。感谢您发布答案。
猜你喜欢
  • 2021-04-30
  • 2023-03-16
  • 2021-12-22
  • 1970-01-01
  • 2020-12-02
  • 2021-05-22
  • 2020-07-22
  • 2021-06-29
  • 2020-10-09
相关资源
最近更新 更多