【问题标题】:heroku can't start nodejs appheroku 无法启动 nodejs 应用程序
【发布时间】:2018-03-28 13:11:13
【问题描述】:

我的应用在本地运行良好。但是当我将它上传到 github 并尝试使用 heroku 启动它时,它会显示“应用程序错误”。构建日志没有显示任何错误,但应用程序日志显示: 我认为我的端口连接是正确的:

const config = {
 port: process.env.PORT || 3000,
};
app.listen(config.port);

package.json:

{
 "name": "labo4",
 "version": "1.0.0",
 "description": "",
 "main": "index.js",
 "scripts": {
  "test": "echo \"Error: no test specified\" && exit 1",
  "start": "nodemon ."
 },
 "author": "",
 "license": "ISC",
 "dependencies": {
  "ejs": "^2.5.7",
  "express": "^4.16.3",
  "glob": "^7.1.2",
  "jade": "^1.11.0",
  "path": "^0.12.7"
 }
}

【问题讨论】:

  • 请分享您的package.json
  • @NikhilSavaliya 我添加了我的 package.json

标签: node.js heroku port


【解决方案1】:

package.json

{
 "name": "labo4",
 "version": "1.0.0",
 "description": "",
 "main": "index.js",
 "scripts": {
  "start": "node index.js"
 },
 "author": "",
 "license": "ISC",
 "dependencies": {
  "ejs": "^2.5.7",
  "express": "^4.16.3",
  "glob": "^7.1.2",
  "jade": "^1.11.0",
  "path": "^0.12.7"
 }
}

默认情况下,Heroku 将在您的 package.json 中搜索开头,因此请按上述方式进行编辑。

【讨论】:

    猜你喜欢
    • 2012-08-23
    • 2013-01-20
    • 2018-10-13
    • 1970-01-01
    • 2011-05-18
    • 2021-12-31
    • 2017-10-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多