【问题标题】:Uncaught Error: JIT compiler unavailable in Angular 12未捕获的错误:Angular 12 中的 JIT 编译器不可用
【发布时间】:2021-11-21 04:00:38
【问题描述】:

这几天我遇到了某个错误的问题:未捕获的错误:JIT 编译器不可用。 将 Angular 从版本 8 升级到 12 后,有一个 我运行 ng build --prod --output-path = dist 命令和 构建Angular我没有问题,但是当我启动页面时,会弹出JIT的这个问题。 我已经尝试了堆栈溢出的所有解决方案,就像我在 package.json 中添加的那样

scripts{
 "postinstall": "ngcc --properties es5 browser module main --first-only"
}

我添加了 main.ts '@angular/compiler' 同样在“angularCompilerOptions”中的 tsconfig.json 中,我将“enableIvy”更改为 true 一篇文章说要更改为 true,另一篇文章说要更改为 false,但这些解决方案都不适合我。 我重新安装 node_modules 几次并添加了几个依赖项,但没有任何效果。 这是我的 tsconfig 文件:

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "module": "es2020",
    "moduleResolution": "node",
    "importHelpers": true,
    "resolveJsonModule": true,
    "target": "es5",
    "skipLibCheck": true, 
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2015",
      "dom"
    ],
    "paths": {
      // "tslib": ["../frontend/node_modules/tslib/tslib.d.ts"]
    }
  },
  "angularCompilerOptions": {
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true,
    "enableIvy": true,
  }
}

在我的 package.json 中我添加了这行代码:

"scripts": {
    "postinstall": "ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points"
}

在 angular.json 中,我更改了 aot: true 和 buildOptimizer: false 但它根本没有改变任何东西。 在这篇文章“https://stackoverflow.com/questions/68798086/jit-compiler-unavailable-after-angular-update”中有答案 关于更改 Webpack 配置。但是我们不使用 webpack,所以我不太明白这一点。 你能帮忙解决这个问题吗?

【问题讨论】:

  • 我面临着类似的问题。你有什么想知道的吗?

标签: angular typescript jit


【解决方案1】:

对我来说,在构建时调用 ng build --aot=true 很有效。可能只是一种解决方法,但我没有找到其他解决方案。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-05-25
    • 2022-12-19
    • 1970-01-01
    • 2019-05-21
    • 2022-07-26
    • 2022-01-04
    • 1970-01-01
    相关资源
    最近更新 更多