NodeJS Heroku部署错误

时间:2015-09-09 06:15:12

标签: 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的新手,请帮助我,谢谢。

1 个答案:

答案 0 :(得分:1)

常见问题,试试这个。

在应用的根目录中添加一个文件:Procfile 它没有扩展名,只有Procfile

在此Procfile中,添加以下内容

web: node ./bin/www

重新编译并重新注入,让我们知道会发生什么。