我正在用NodeJS创建一个聊天应用程序,并且我想部署到Heroku。但是,通过使用Github部署,我得到一个错误:An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details.
。有谁知道发生了什么事?如何将NodeJS应用程序部署到Heroku?
Here is some code to see what I have done.
{
"name": "chat",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./lib/index.js",
"test": "jasmine"
},
"dependencies": {
"express": "~4.13.1",
"firebase": "^3.9.0",
"request-promise": "^2.0.1",
"socket.io": "^1.4.5"
},
"devDependencies": {
"jasmine-sinon": "^0.4.0",
"jscs": "^2.11.0",
"proxyquire": "^1.7.4",
"rewire": "^2.5.1",
"sinon": "^1.17.3"
}
}
index.js (Server)
var express = require('express');
var app = express();
var path = require('path');
var http = require('http').Server(app);
var io = require('socket.io')(http);
var routes = require('./routes');
var chats = require('./chat');
app.use(express.static(path.join(__dirname, '../public')));
routes.load(app);
chats.load(io);
var port = process.env.PORT || 3000;
app.listen(port);
console.log('Server is listening at port:' + port);
查看'heroku logs -t',它通常会显示更多关于您的应用崩溃原因的信息。 –
我可以告诉你我的github项目,看看我做错了吗?我想要做的就是在heroku中使用Github部署 –
当然,您也可以通过本指南,因为它可以帮助您将GH部署集成到Heroku中https://devcenter.heroku.com/articles/github-integration –