【问题标题】:What are minimum lines of codes for Heroku's package.json file?Heroku 的 package.json 文件的最少代码行数是多少?
【发布时间】:2020-08-08 17:34:50
【问题描述】:
我正在构建并成功部署到 Heroku master。但是 node.js 应用程序不起作用。 (系统没有指明错误。)
我的文件夹中有两个文件:
- index.js
- package.json
index.js 文件包含在 vanilla node.js 中创建服务器的最少代码。 package.json 文件包含此代码,我怀疑我需要添加一些内容。非常感谢您的帮助!
{
"name": "siatest88",
"description": "Our sampe Node to",
"main": "index.js",
"scripts": {
"start": "node index.js"
}
}
【问题讨论】:
标签:
node.js
heroku
deployment
【解决方案1】:
对于任何面临类似问题的人。值得在控制台中输入“heroku 日志”。这揭示了以下错误。
Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
Stopping process with SIGKILL
Process exited with status 137
State changed from starting to crashed
问题出在 index.js 文件中。端口需要定义为“let port = process.env.PORT || 80”。然后就可以了。
看来我原帖中的极简 package.json 文件足以在 Heroku 上正确配置。