使用Angular了解Heroku日志

时间:2018-09-13 10:17:09

标签: angular heroku

我有一个在本地主机上运行良好的Angular应用程序,但是当我上传到Heroku时,我收到了一个错误。

2018-09-13T09:33:53.944829+00:00 app[web.1]: > ng serve
2018-09-13T09:33:53.944831+00:00 app[web.1]:
2018-09-13T09:33:53.954809+00:00 app[web.1]: sh: 1: ng: not found
2018-09-13T09:33:53.967562+00:00 app[web.1]: npm ERR! file sh
2018-09-13T09:33:53.967902+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2018-09-13T09:33:53.968250+00:00 app[web.1]: npm ERR! errno ENOENT
2018-09-13T09:33:53.968589+00:00 app[web.1]: npm ERR! syscall spawn
2018-09-13T09:33:53.970548+00:00 app[web.1]: npm ERR! taccountproui@0.0.0 
start: `ng serve`
2018-09-13T09:33:53.970808+00:00 app[web.1]: npm ERR! spawn ENOENT
2018-09-13T09:33:53.971162+00:00 app[web.1]: npm ERR!
2018-09-13T09:33:53.971426+00:00 app[web.1]: npm ERR! Failed at the 
taccountproui@0.0.0 start script.
2018-09-13T09:33:53.971682+00:00 app[web.1]: npm ERR! This is probably not a 
problem with npm. There is likely additional logging output above.
2018-09-13T09:33:54.000551+00:00 app[web.1]: npm ERR! A complete log of this 
run can be found in:
2018-09-13T09:33:53.994215+00:00 app[web.1]:
2018-09-13T09:33:54.000772+00:00 app[web.1]: npm ERR!     
/app/.npm/_logs/2018-09-13T09_33_53_973Z-debug.log
2018-09-13T09:33:58.000000+00:00 app[api]: Build succeeded
2018-09-13T09:34:03.177179+00:00 app[web.1]:
2018-09-13T09:34:03.177204+00:00 app[web.1]: > ng serve
2018-09-13T09:34:03.177202+00:00 app[web.1]: > taccountproui@0.0.0 start 
/app
2018-09-13T09:34:03.177206+00:00 app[web.1]:
2018-09-13T09:34:03.193831+00:00 app[web.1]: npm ERR! file sh
2018-09-13T09:34:03.194392+00:00 app[web.1]: npm ERR! errno ENOENT
2018-09-13T09:34:03.194631+00:00 app[web.1]: npm ERR! syscall spawn
2018-09-13T09:34:03.188316+00:00 app[web.1]: sh: 1: ng: not found
2018-09-13T09:34:03.196406+00:00 app[web.1]: npm ERR! taccountproui@0.0.0 
start: `ng serve`
2018-09-13T09:34:03.194141+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2018-09-13T09:34:03.208289+00:00 app[web.1]: npm ERR! A complete log of this 
run can be found in:
2018-09-13T09:34:03.196593+00:00 app[web.1]: npm ERR! spawn ENOENT
2018-09-13T09:34:03.197062+00:00 app[web.1]: npm ERR! Failed at the 
taccountproui@0.0.0 start script.
2018-09-13T09:34:03.196865+00:00 app[web.1]: npm ERR!
2018-09-13T09:34:03.197294+00:00 app[web.1]: npm ERR! This is probably not a 
problem with npm. There is likely additional logging output above.
2018-09-13T09:34:03.208066+00:00 app[web.1]:
2018-09-13T09:34:03.208437+00:00 app[web.1]: npm ERR!     
/app/.npm/_logs/2018-09-13T09_34_03_199Z-debug.log

我找不到错误。 /app/.npm/_logs/2018-09-13T09_34_03_199Z-debug.log文件在哪里?

这里还有更多日志:

    2018-09-12T18:30:39.210236+00:00 heroku[router]: at=error code=H10 
    desc="App crashed" method=GET path="/" host=taccountproui.herokuapp.com 
    request_id=6b006b87-9290-4b12-bae8-73e8e620ecbf fwd="86.40.243.210" 
    dyno= connect= service= status=503 bytes= protocol=https
    2018-09-12T18:30:41.427199+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=taccountproui.herokuapp.com request_id=2f4b89de-5746-4e8c-b2b3-fff0a0ecdfda fwd="86.40.243.210" dyno= connect= service= status=503 bytes= protocol=https

2018-09-12T18:30:53.477386 + 00:00 heroku [router]:at =错误代码= H10 desc =“应用程序崩溃”,方法= GET path =“ /” host = taccountproui.herokuapp.com request_id = 1dd887be-b7fa-4c0b-b657-ea8d773082f4 fwd =“ 86.40.243.210” dyno = connect = service = status = 503字节= protocol = https 2018-09-12T18:30:54.380182 + 00:00 heroku [router]:at =错误代码= H10 desc =“应用程序崩溃”方法= GET路径=“ / favicon.ico”主机= taccountproui.herokuapp.com request_id = bb69a40b-52b4-4ff8-b4f7-9391c3a8ed67 fwd =“ 86.40.243.210” dyno = connect = service = status = 503字节= protocol = https

1 个答案:

答案 0 :(得分:1)

ng伺服不适用于heroku。 建议使其运行的方法是在项目文件夹中添加文件(Procfile)。
Procfile:

web: node dist/server

Heroku将使用该过程来启动您的应用程序,而不是package.json中的启动脚本。

您还可以为package.json创建一个新的脚本命令。例如:

"serveonheroku": "node dist/server",

和Procfile:

web: npm run serveonheroku