heroku无法启动nodejs app

时间:2018-03-28 13:11:14

标签: node.js heroku port

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

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"
 }
}

1 个答案:

答案 0 :(得分:2)

<强>的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中搜索一个开头,因此请按上述方式对其进行修改。