[英]Error: Runtime compiler is not loaded Error: Runtime compiler is not loaded in angular 2
In my angular2 project I have used compiler service to make a dynamic module and render it at runtime in the app. 在我的angular2项目中,我使用了编译器服务来制作一个动态模块,并在运行时在应用程序中对其进行呈现。 Issue is that when I run the command ng build --prod, it completed process without any error but after hosting it to the herokuapp If I run my app , it gives me error like,
问题是,当我运行ng build --prod命令时,它完成了整个过程,没有任何错误,但是将其托管到herokuapp之后。如果我运行我的应用程序,它会给我类似的错误,
core.js.pre-build-optimizer.js:15714
ERROR Error: Uncaught (in promise): Error: Runtime compiler is not loaded Error: Runtime compiler is not loaded 错误错误:未捕获(承诺):错误:未加载运行时编译器错误:未加载运行时编译器
at t.rd (core.js.pre-build-optimizer.js:16852)
at e.<anonymous> (pdf-load.component.ts:69)
at tslib.es6.js.pre-build-optimizer.js:97
at Object.next (tslib.es6.js.pre-build-optimizer.js:78)
at tslib.es6.js.pre-build-optimizer.js:71
at new t (zone.js.pre-build-optimizer.js:910)
at Object.u (tslib.es6.js.pre-build-optimizer.js:67)
at e._next (pdf-load.component.ts:55)
at e.__tryOrUnsub (Subscriber.js.pre-build-optimizer.js:196)
at e.next (Subscriber.js.pre-build-optimizer.js:134)
at P (zone.js.pre-build-optimizer.js:831)
at new t (zone.js.pre-build-optimizer.js:913)
at Object.u (tslib.es6.js.pre-build-optimizer.js:67)
at e._next (pdf-load.component.ts:55)
at e.__tryOrUnsub (Subscriber.js.pre-build-optimizer.js:196)
at e.next (Subscriber.js.pre-build-optimizer.js:134)
at e._next (Subscriber.js.pre-build-optimizer.js:77)
at e.next (Subscriber.js.pre-build-optimizer.js:54)
at e._next (map.js.pre-build-optimizer.js:41)
at e.next (Subscriber.js.pre-build-optimizer.js:54)
How can I resolve this error? 如何解决此错误?
Heroku uses postinstall
and preinstall
hooks which you can use to build: Heroku使用
postinstall
和preinstall
挂钩 ,您可以使用它们来构建:
"preinstall": "npm install -g http-server",
"postinstall": "ng build --prod"
You can also use the "start" hook to serve: 您也可以使用“开始”钩子来服务:
"start": "http-server dist/"
If anyone needs to deploy to heroku, pls, read this article first: https://m.alphasights.com/using-nginx-on-heroku-to-serve-single-page-apps-and-avoid-cors-5d013b171a45#.drmqhuard 如果有人需要部署到heroku,请先阅读以下文章: https : //m.alphasights.com/using-nginx-on-heroku-to-serve-single-page-apps-and-avoid-cors-5d013b171a45 #.drmqhuard
Use this build pack: https://github.com/heroku/heroku-buildpack-static 使用此构建包: https : //github.com/heroku/heroku-buildpack-static
And this static.json: 而这个static.json:
{
"root": "dist/",
"routes": {
"/**": "index.html"
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.