angular - Angular 9 Unhandled Promise 拒绝:Angular JIT 编译失败错误
问题描述
我将我们的应用程序升级到 Angular 9,但在生产测试中我收到了这个错误。ng serve --optimization=true --aot=true --prod
在将其部署到生产之前,我正在使用命令为我的应用程序提供服务,但它只是无法正常工作
Unhandled Promise rejection: Angular JIT compilation failed: '@angular/compiler' not loaded!
- JIT compilation is discouraged for production use-cases! Consider AOT mode instead.
- Did you bootstrap using '@angular/platform-browser-dynamic' or '@angular/platform-server'?
- Alternatively provide the compiler with 'import "@angular/compiler";' before bootstrapping. ; Zone: <root> ;
这是指向我的 polyfills.ts
我已将 import "@angular/compiler 添加到我的 main.ts 文件的顶部,但没有成功。
除了 zone.js 之外,我还从 polyfill 中删除了所有导入,但仍然出现错误。
这是什么意思,如何解决?
解决方案
您需要在 main.ts 文件的最顶部导入“@angular/compiler”,但既然您已经拥有它,那么
你必须在你的 package.json 中运行它
scripts{
"postinstall": "ngcc --properties es5 browser module main --first-only"
}
推荐阅读
- r - R中的查找表
- ios - Firebase 身份验证未按预期工作。用户正在登录主屏幕或注册页面
- r - 数据表 R:合并来自多个 data.table 的选定列
- autodesk-forge - 缺少 Edit2D 事件的字符串是什么?
- kubernetes - 为主管道和底层管道保留相同的 jenkins 代理 pod
- python - 用里面的字符串对列表进行排序
- java - 在反应流中对项目进行分组
- python - 为什么 python 从备用路径导入共享对象时会抛出未定义符号错误?
- html - Google HTML 服务 - 评估模板并保留评论
- python-xarray - 打开具有许多组的远程 zarr 存储并使用 xarray 保持坐标