【发布时间】:2015-09-16 14:10:23
【问题描述】:
我正在尝试将 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);
我正在浏览一个教程,但没有从作者那里得到任何帮助,所以希望这里有人能指出我正确的方向。
谢谢。
【问题讨论】: