在我的angular2项目中,我使用了编译器服务来制作一个动态模块,并在应用程序中在运行时进行渲染。问题是,当我运行ng build --prod命令时,它完成了整个过程,没有任何错误,但是将其托管到herokuapp之后。如果我运行我的应用程序,它将给我类似的错误,
core.js.pre-build-optimizer.js:15714
错误 错误:未捕获(承诺):错误:未加载运行时编译器 错误:未加载运行时编译器
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)
如何解决此错误?
答案 0 :(得分:0)
Heroku uses postinstall
and preinstall
hooks,可用于构建:
"preinstall": "npm install -g http-server",
"postinstall": "ng build --prod"
您还可以使用“开始”钩服务:
"start": "http-server dist/"
如果有人需要部署到heroku,请先阅读此文章: https://m.alphasights.com/using-nginx-on-heroku-to-serve-single-page-apps-and-avoid-cors-5d013b171a45#.drmqhuard
使用此构建包:https://github.com/heroku/heroku-buildpack-static
还有这个static.json:
{
"root": "dist/",
"routes": {
"/**": "index.html"
}
}