herokuページを読み込むときにアプリケーションエラーが発生しました。私はここに指示に従ったhttps://devcenter.heroku.com/articles/deploying-nodejs。Node.js Herokuアプリケーションエラーのチャットルーム
私のコードはこのビルドの調整版ですhttps://enlight.ml/nodejs-chatです。
私のノードserver.jsファイルの一部です。
var express = require('express');
var app = express();
var server = require('http').createServer(app);
var io = require('socket.io')(server);
var people = {};
var heads = [];
app.get('/', function(req, res, next) {
res.sendFile(__dirname + '/public/index.html')
});
server.listen(process.env.PORT || 5000);
Herokuのログ。
2017-03-27T05:40:05.790068+00:00 heroku[web.1]: State changed from crashed to starting
2017-03-27T05:40:07.296635+00:00 heroku[web.1]: Starting process with command `node server.js`
2017-03-27T05:40:09.867374+00:00 app[web.1]: module.js:471
2017-03-27T05:40:09.867387+00:00 app[web.1]: throw err;
2017-03-27T05:40:09.867387+00:00 app[web.1]: ^
2017-03-27T05:40:09.867388+00:00 app[web.1]:
2017-03-27T05:40:09.867389+00:00 app[web.1]: Error: Cannot find module 'socket.io'
2017-03-27T05:40:09.867390+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:469:15)
2017-03-27T05:40:09.867390+00:00 app[web.1]: at Function.Module._load (module.js:417:25)
2017-03-27T05:40:09.867391+00:00 app[web.1]: at Module.require (module.js:497:17)
2017-03-27T05:40:09.867392+00:00 app[web.1]: at require (internal/module.js:20:19)
2017-03-27T05:40:09.867392+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:4:30)
2017-03-27T05:40:09.867393+00:00 app[web.1]: at Module._compile (module.js:570:32)
2017-03-27T05:40:09.867393+00:00 app[web.1]: at Object.Module._extensions..js (module.js:579:10)
2017-03-27T05:40:09.867395+00:00 app[web.1]: at Function.Module._load (module.js:438:3)
2017-03-27T05:40:09.867394+00:00 app[web.1]: at tryModuleLoad (module.js:446:12)
2017-03-27T05:40:09.867394+00:00 app[web.1]: at Module.load (module.js:487:32)
2017-03-27T05:40:09.947727+00:00 heroku[web.1]: State changed from starting to crashed
2017-03-27T05:40:09.928089+00:00 heroku[web.1]: Process exited with status 1
package.json。ファイル.gitignore
{
"name": "im",
"version": "1.0.0",
"description": "Messaging App",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/username/im.git"
},
"author": "me",
"license": "ISC",
"bugs": {
"url": "https://github.com/username/im/issues"
},
"homepage": "https://github.com/username/im#readme",
"dependencies": {
"express": "4.15.2"
},
"engines": {
"node": "6.10.0"
},
"devDependencies": {},
"keywords": [
"chat",
"app"
]
}
。
/node_modules
npm-debug.log
.DS_Store
/*.env