【发布时间】:2020-04-21 08:38:54
【问题描述】:
我将我们的应用程序升级到 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 文件的顶部,但没有成功。
我还从 polyfill 中删除了除 zone.js 之外的所有导入,但仍然出现错误。
这是什么意思,如何解决?
【问题讨论】:
-
尝试使用
ng build --prod编译生产环境,并使用lite-server之类的东西作为per docs 提供服务。 -
编译不是问题,它运行出现错误的应用程序。我将它部署到了一个模拟我们的生产环境的测试服务器上,并且出现了同样的错误
标签: angular