Angular JIT 编译失败:“@angular/compiler”未加载!
- 对于生产用例,不鼓励使用 JIT 编译!请考虑使用 AOT 模式。
- 您是否使用“@angular/platform-browser-dynamic”或“@angular/platform-server”进行引导?
- 或者为编译器提供 'import "@angular/compiler";'在引导之前。
在开发模式下构建生产构建时出现此错误,但没有出现任何错误
您可以尝试以下任一解决方案:
解决方案1
运行以下命令来更新所有依赖项,因为它们可能存在一些不兼容性:
npm update
解决方案2
确保您已经导入'@angular/compiler'
在你的最顶部main.ts
file.
现在设置以下行
aot=true
in angular.json
file.
另外,设置以下行
scripts{
"postinstall": "ngcc --properties es2015 browser module main --first- only --create-ivy-entry-points"
}
in package.json
文件然后删除node_modules
文件夹和package-lock.json
文件,然后运行以下命令:
npm install
解决方案3
禁用 Ivy 引擎tsconfig.json
file:
"angularCompilerOptions": { "fullTemplateTypeCheck": true, "strictInjectionParameters": true, "enableIvy": false }
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)