【问题标题】:Heroku's crashed using Node.jsHeroku 使用 Node.js 崩溃了
【发布时间】:2022-01-12 23:55:46
【问题描述】:

我一直在尝试部署我的网站。它可以在我的本地计算机上运行,​​但是当我将它部署到 Heroku 时它不起作用。

这是 Heroku 的日志:

2022-01-12T09:31:04.854187+00:00 heroku[web.1]: Process exited with status 1
2022-01-12T09:31:05.082730+00:00 heroku[web.1]: State changed from starting to crashed
2022-01-12T15:07:15.575516+00:00 heroku[web.1]: State changed from crashed to starting
2022-01-12T15:07:17.952102+00:00 heroku[web.1]: Starting process with command `npm start`
2022-01-12T15:07:19.220594+00:00 app[web.1]: npm ERR! missing script: start
2022-01-12T15:07:19.224923+00:00 app[web.1]: 
2022-01-12T15:07:19.225102+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2022-01-12T15:07:19.225149+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2022-01-12T15_07_19_221Z-debug.log
2022-01-12T15:07:19.394790+00:00 heroku[web.1]: Process exited with status 1
2022-01-12T15:07:19.459851+00:00 heroku[web.1]: State changed from starting to crashed

【问题讨论】:

  • missing script: start - 你定义了一个启动脚本吗?这就是 Heroku requires by default。给minimal reproducible example
  • 如果您愿意,您也可以在Procfile 中指定您的流程。 Heroku 优先使用它而不是启动脚本(如果存在)。

标签: node.js heroku


【解决方案1】:

您需要在您的package.json 中定义一个start 脚本。举个例子:

{
  "name": "your-project",
  "version": "1.0",
  "description": "Your project description",
  "scripts": {
    "start": "node src/index.js" // or wherever your `index.js` is
  },
  ...
}

【讨论】:

    猜你喜欢
    • 2012-05-02
    • 1970-01-01
    • 2016-08-04
    • 2019-05-15
    • 2015-12-01
    • 2018-07-09
    • 2014-10-22
    • 2015-03-02
    • 1970-01-01
    相关资源
    最近更新 更多