问题描述
使用--prod
标志构建Angular2应用后,出现以下运行时错误:
I am getting the following runtime error after building my Angular2 app with the --prod
flag:
我了解生产版本使用AoT,并且在这种情况下不支持运行时编译.
我的问题是:我不知道自己正在做的任何事情都需要运行时编译器.甚至可能是我正在使用的外部组件.
I understand that the production builds use AoT and that runtime compiling isn't supported in this scenario.
My problem is: I am not aware of anything I am doing that would need the runtime compiler. It might even be an external component I am using.
我如何找出导致此错误的组件?
How do I find out what component is causing this error?
推荐答案
当我尝试使用模块类型而不是路径来使用惰性模块加载时,AoT编译也遇到了类似的问题.
I have had the similar issue with AoT compilation when I was trying to use lazy module loading using module type instead of the path.
正确加载:
{ path: 'lazy', loadChildren: 'lazy/lazy.module#LazyModule' }
我已经做到了(崩溃了AoT):
Way, I've done it (crashes AoT):
export function loadLazyModule() {
return LazyModule;
}
export const appRoutes: Routes = [
{ path: 'lazy', loadChildren: loadLazyModule, },
];
实际上,错误消息根本没有帮助,但是堆栈跟踪为:
Indeed the error message is not helpful at all, however, the stack trace is:
at Compiler.compileModuleAsync (core.js:3664)
at MergeMapSubscriber.eval [as project] (router.js:4467)
我刚刚在compileModuleAsync
函数中创建了一个断点,然后在停止处我看到了导致错误的模块.
I've just made a breakpoint at compileModuleAsync
function and at the stop I saw the module which was causing the error.
这篇关于故障排除“未加载运行时编译器";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!