平均应用程序deplouy到heroku错误

我正在尝试将一个node.js应用程序部署到heroku。

一切似乎都很好,直到我试图通过与Heroku的应用程序打开

heroku open 

我然后得到

 Opening nameless-taiga-6317... done 

但是我的浏览器出现了应用程序错误,而且heroku日志吐出了这个消息:

 ←[36m2015-06-29T20:56:25.562616+00:00 heroku[web.1]:←[0m Process exited with status 1 ←[36m2015-06-29T20:56:27.685099+00:00 heroku[web.1]:←[0m Starting process with command `npm start` ←[36m2015-06-29T20:56:29.513842+00:00 app[web.1]:←[0m Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY) ←[36m2015-06-29T20:56:29.513866+00:00 app[web.1]:←[0m Recommending WEB_CONCURRENCY=1 ←[36m2015-06-29T20:56:30.256436+00:00 app[web.1]:←[0m npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start" ←[36m2015-06-29T20:56:30.257127+00:00 app[web.1]:←[0m npm ERR! npm v2.11.2 ←[36m2015-06-29T20:56:30.255876+00:00 app[web.1]:←[0m npm ERR! Linux 3.13.0-49-generic ←[36m2015-06-29T20:56:30.256743+00:00 app[web.1]:←[0m npm ERR! node v0.12.5 ←[36m2015-06-29T20:56:30.257367+00:00 app[web.1]:←[0m ←[36m2015-06-29T20:56:30.257575+00:00 app[web.1]:←[0m npm ERR! missing script: start ←[36m2015-06-29T20:56:30.257725+00:00 app[web.1]:←[0m npm ERR! ←[36m2015-06-29T20:56:30.257836+00:00 app[web.1]:←[0m npm ERR! If you need help, you may report this error at: ←[36m2015-06-29T20:56:30.257951+00:00 app[web.1]:←[0m npm ERR! <https://github.com/npm/npm/issues> ←[36m2015-06-29T20:56:30.263537+00:00 app[web.1]:←[0m ←[36m2015-06-29T20:56:30.263763+00:00 app[web.1]:←[0m npm ERR! Please include the following file with any support request: ←[36m2015-06-29T20:56:30.264024+00:00 app[web.1]:←[0m npm ERR! /app/npm-debug.log ←[36m2015-06-29T20:56:31.030724+00:00 heroku[web.1]:←[0m Process exited with status 1 ←[36m2015-06-29T20:56:31.048838+00:00 heroku[web.1]:←[0m State changed from starting to crashed ←[33m2015-06-29T21:01:55.665028+00:00 heroku[api]:←[0m Scale to web=1 by david.shave@gmail.com ←[32m2015-06-29T21:02:35.497433+00:00 heroku[router]:←[0m at=error code=H10 desc="App crashed" method=GET path="/" host=nameless-taiga-6317.herokuapp.com ... 

这是我的一些server.js文件

 var mongoose = require('mongoose'); 

….

 //connect database if (env === 'development') { mongoose.connect('mongodb://localhost/multivision'); } else { mongoose.connect('mongodb://amp3rsand:multivision@ds039550.mongolab.com:39550/multivision'); } 

….

 var db = mongoose.connection; db.on('error', console.error.bind(console, 'connection error...')); db.once('open', function callback() { console.log('multivision db opened'); }); 

 var port = process.env.PORT || 3030; app.listen(port); 

我正在通过一个教程,但没有得到作者的任何帮助,所以希望在这里有人能指出我在正确的方向。

谢谢。

你目前缺less一个npm开始脚本 – Heroku不知道如何运行你的应用程序。 你有两个select:

在你的package.json文件中定义一个启动脚本,或者你可以创build一个Procfile来告诉Heroku如何运行你的应用程序。

这是一个例子:

 # Procfile web: node index.js # Tell Heroku what command to use to run your app.