node.js - NodeJS Heroku 部署错误

标签 node.js heroku

当我将我的应用程序从 github 部署到 Heroku 时,在我的 Heroku 仪表板上显示我的应用程序已成功部署。但是,当我查看我的应用程序时,它显示应用程序错误。

这是我的日志:

2015-09-09T05:54:41.566570+00:00 heroku[web.1]: State changed from starting to crashed
2015-09-09T05:54:41.566570+00:00 heroku[web.1]: State changed from crashed to starting
2015-09-09T05:54:41.542661+00:00 heroku[web.1]: Process exited with status 1
2015-09-09T05:54:43.511445+00:00 heroku[web.1]: Starting process with command `npm start`
2015-09-09T05:54:45.973805+00:00 app[web.1]:
2015-09-09T05:54:45.973825+00:00 app[web.1]: > mark-wen-home@1.0.0 start /app
2015-09-09T05:54:45.973828+00:00 app[web.1]: > node server.js
2015-09-09T05:54:45.973829+00:00 app[web.1]:
2015-09-09T05:54:46.306616+00:00 app[web.1]: events.js:85
2015-09-09T05:54:46.306620+00:00 app[web.1]:       throw er; // Unhandled 'error' event
2015-09-09T05:54:46.306621+00:00 app[web.1]:             ^
2015-09-09T05:54:46.306623+00:00 app[web.1]: Error: listen EACCES
2015-09-09T05:54:46.306624+00:00 app[web.1]:     at exports._errnoException (util.js:746:11)
2015-09-09T05:54:46.306625+00:00 app[web.1]:     at Server._listen2 (net.js:1139:19)
2015-09-09T05:54:46.306626+00:00 app[web.1]:     at listen (net.js:1182:10)
2015-09-09T05:54:46.306628+00:00 app[web.1]:     at Server.listen (net.js:1267:5)
2015-09-09T05:54:46.306629+00:00 app[web.1]:     at EventEmitter.listen (/app/node_modules/express/lib/application.js:617:24)
2015-09-09T05:54:46.306630+00:00 app[web.1]:     at Object.<anonymous> (/app/server.js:6:18)
2015-09-09T05:54:46.306631+00:00 app[web.1]:     at Module._compile (module.js:460:26)
2015-09-09T05:54:46.306633+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:478:10)
2015-09-09T05:54:46.306634+00:00 app[web.1]:     at Module.load (module.js:355:32)
2015-09-09T05:54:46.306635+00:00 app[web.1]:     at Function.Module._load (module.js:310:12)
2015-09-09T05:54:46.319744+00:00 app[web.1]:
2015-09-09T05:54:46.325322+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2015-09-09T05:54:46.325562+00:00 app[web.1]: npm ERR! node v0.12.7
2015-09-09T05:54:46.325986+00:00 app[web.1]: npm ERR! npm  v2.11.3
2015-09-09T05:54:46.326180+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2015-09-09T05:54:46.326474+00:00 app[web.1]: npm ERR! mark-wen-home@1.0.0 start: `node server.js`
2015-09-09T05:54:46.326627+00:00 app[web.1]: npm ERR! Exit status 1
2015-09-09T05:54:46.326774+00:00 app[web.1]: npm ERR!
2015-09-09T05:54:46.326914+00:00 app[web.1]: npm ERR! Failed at the mark-wen-home@1.0.0 start script 'node server.js'.
2015-09-09T05:54:46.327140+00:00 app[web.1]: npm ERR! This is most likely a problem with the mark-wen-home package,
2015-09-09T05:54:46.327330+00:00 app[web.1]: npm ERR! not with npm itself.
2015-09-09T05:54:46.327495+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2015-09-09T05:54:46.327804+00:00 app[web.1]: npm ERR!     node server.js
2015-09-09T05:54:46.327908+00:00 app[web.1]: npm ERR! You can get their info via:
2015-09-09T05:54:46.328139+00:00 app[web.1]: npm ERR!     npm owner ls mark-wen-home
2015-09-09T05:54:46.328335+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2015-09-09T05:54:46.331322+00:00 app[web.1]:
2015-09-09T05:54:46.331590+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2015-09-09T05:54:46.331796+00:00 app[web.1]: npm ERR!     /app/npm-debug.log
2015-09-09T05:54:46.324727+00:00 app[web.1]: npm ERR! Linux 3.13.0-61-generic
2015-09-09T05:54:47.275838+00:00 heroku[web.1]: State changed from starting to crashed
2015-09-09T05:54:47.256020+00:00 heroku[web.1]: Process exited with status 1
2015-09-09T06:02:13.416277+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=mark-wen-home.herokuapp.com request_id=1ef25e3b-07c1-4d3c-b076-1340b63418b9 fwd="72.12.205.35" dyno= connect= service= status=503 bytes=
2015-09-09T06:02:13.809318+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=mark-wen-home.herokuapp.com request_id=8a4ba90e-6596-40e7-a5a0-72f829a5b90f fwd="72.12.205.35" dyno= connect= service= status=503 bytes=

这是我的 server.js,以备不时之需:

var express = require('express');
var app = express();

app.use(express.static(__dirname + '/public'));

var server = app.listen(80, function () {
  var port = server.address().port;
  console.log('Listening at port ' + port);
});

我是 Heroku 的新手,请帮我解决这个问题,谢谢。

最佳答案

尝试像这样使用 (process.env.PORT || 80)) 而不是 80

关于node.js - NodeJS Heroku 部署错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32472139/

相关文章:

javascript - 为什么 JavaScript 中可以将参数传递给没有参数的函数?

node.js - 是否可以将 "next/react + node/express"Web 应用程序部署到一个服务器帐户中,例如 heroku?

python - Heroku 应用程序 : ModuleNotFoundError: No module named 'pwa'

sql - 即使是很小的 table ,ALTER TABLE 也需要很长时间

即使没有实际的新迁移,Django 迁移命令也会卡在 Heroku 上

javascript - 如何扩展nodejs模块

node.js - Docker compose up 'Exec format error' 加载库

python - SpaCyOS错误: [E050] Can't find model 'en' on Heroku platform

django - 如何使用 Mercurial 将文件夹与现有 Heroku 应用程序链接

javascript - 将库从 Node 模块加载到 nodeJS