【问题标题】:understanding heroku log using Angular使用 Angular 理解 heroku 日志
【发布时间】:2019-02-18 01:33:03
【问题描述】:

我有一个 Angular 应用程序在 localhost 上运行良好,但是当我上传到 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=error code=H10 desc="App crashed" method=GET path="/" host=taccountproui.herokuapp.com request_id= 1dd887be-b7fa-4c0b-b657-ea8d773082f4 fwd="86.40.243.210" 测功机=连接=服务=状态=503字节=协议=https 2018-09-12T18:30:54.380182+00:00 heroku[路由器]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=taccountproui.herokuapp.com request_id= bb69a40b-52b4-4ff8-b4f7-9391c3a8ed67 fwd="86.40.243.210" dyno= connect= service= status=503 bytes= protocol=https

【问题讨论】:

  • 你可以先运行一下吗? npm link @angular/cli这是为了让npm知道ng是什么意思
  • 当我运行时我得到:C:\Users\laptop\Documents\t account pro angular\taccountproui\node_modules\@angular\cli -> C:\Users\laptop\AppData\Roaming\npm \node_modules\@angular\cli
  • 您不会收到错误消息,对吧?现在尝试构建
  • 没有错误。通过构建你是什么意思?再次上传到 Heroku 或在本地运行
  • 我如何查看导致错误的原因?

标签: angular heroku


【解决方案1】:

ng serve 不适用于 heroku。 让它运行的推荐方法是在您的项目文件夹中添加一个文件 (Procfile)。
简介:

web: node dist/server

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

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

"serveonheroku": "node dist/server",

和 Procfile:

web: npm run serveonheroku

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-05
    相关资源
    最近更新 更多