如果我尝试打开heroku网站,则会收到应用程序错误。如果我在终端中运行heroku日志--tail,则会出现错误:at =错误代码= H10 desc =“应用程序崩溃”方法=获取路径=“ /” host = unidicks.herokuapp.com request_id = 32754547-c705-4a11 -9364-39a2168f7a71 fwd =“ 84.195.162.123” dyno = connect =服务=状态= 503字节=协议= https。我怎样才能解决这个问题?
index.js :
var express = require('express');
var socket = require('socket.io');
// App setup
var app = express();
var server = app.listen(process.env.PORT || 4000, function(){
console.log('listening for requests on port 4000,');
});
// Static files
app.use(express.static('public'));
// Socket setup & pass server
var io = socket(server);
io.on('connection', (socket) => {
console.log('made socket connection', socket.id);
// Handle chat event
socket.on('chat', function(data){
// console.log(data);
io.sockets.emit('chat', data);
});
// Handle typing event
socket.on('typing', function(data){
socket.broadcast.emit('typing', data);
});
});
procfile:
web:节点index.js
package.json:
´{
"name": "websockets-playlist",
"version": "1.0.0",
"description": "A chat app using WebSockets",
"main": "index.js",
"scripts": {
"start": "node app"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/iamshaunjp/websockets-playlist.git"
},
"author": "The Net Ninja",
"license": "ISC",
"bugs": {
"url": "https://github.com/iamshaunjp/websockets-playlist/issues"
},
"homepage": "https://github.com/iamshaunjp/websockets-playlist#readme",
"dependencies": {
"express": "^4.17.1",
"socket.io": "^1.7.4"
},
"devDependencies": {
"nodemon": "^1.19.4"
}
}`