几天来我遇到了某个错误:未捕获错误:JIT 编译器不可用。将 Angular 从版本 8 升级到 12 后出现了一个问题,我运行 ng build --prod --output-path = dist 命令并构建 Angular 我没有问题,但是当我启动页面时,会弹出这个 JIT 问题。我已经尝试了堆栈溢出中的所有解决方案,就像我在 package.json 中添加的那样
scripts{
"postinstall": "ngcc --properties es5 browser module main --first-only"
}Run Code Online (Sandbox Code Playgroud)
我在 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", …Run Code Online (Sandbox Code Playgroud)