在部署到Heroku时出现错误:找不到模块“express-session”。

3
我是一名初学者,正在尝试将我的Node应用部署到Heroku。从下面的日志中我了解到,Heroku无法读取express-session依赖项。因此,我检查了我的package.json文件,发现它不在其中,尽管在我的app.js文件中进行了'引用'。即使没有使用express-session,它也在本地使用nodemon运行得很好。
考虑到这可能会导致错误消息,我在依赖项中添加了'express-session'。然后我在命令行中运行了npm install express-session、npm install、git add和git commit,然后将其推回Heroku。然而,仍然出现相同的错误。
这是我的依赖项:
{
  "name": "simplyfly",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "bcrypt": "^0.8.2",
    "body-parser": "^1.12.2",
    "ejs": "^2.3.1",
    "express": "^4.12.3",
    "method-override": "^2.3.2",
    "pg": "^4.3.0",
    "pg-hstore": "^2.3.2",
    "request": "^2.55.0",
    "sequelize": "^2.0.5",
    "sequelize-cli": "^1.7.0",
    "cool-ascii-faces": "~1.3.x",
    "express-session": "^1.7.6"
  }
}

以下是我的日志记录:

2015-06-15T20:13:20.488264+00:00 app[web.1]:     at Module.load (module.js:355:32)
2015-06-15T20:13:20.488268+00:00 app[web.1]:     at Function.Module.runMain (module.js:501:10)
2015-06-15T20:13:20.488265+00:00 app[web.1]:     at Function.Module._load (module.js:310:12)
2015-06-15T20:13:21.385482+00:00 heroku[web.1]: Process exited with status 1
2015-06-15T20:13:21.421482+00:00 heroku[web.1]: State changed from starting to crashed
2015-06-15T20:13:33.850256+00:00 heroku[api]: Scale to web=1 by c.kazbour@gmail.com
2015-06-15T20:13:42.056575+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=simplifly.herokuapp.com request_id=cbef7e0e-24cb-45f1-9934-7a326a514ed4 fwd="50.141.68.137" dyno= connect= service= status=503 bytes=
2015-06-15T20:13:48.199162+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=simplifly.herokuapp.com request_id=7ba21844-6623-4d9c-af76-ffa60cad4fbd fwd="50.141.68.137" dyno= connect= service= status=503 bytes=
2015-06-15T20:26:58.464510+00:00 heroku[api]: Deploy 36f1770 by c.kazbour@gmail.com
2015-06-15T20:26:58.464510+00:00 heroku[api]: Release v4 created by c.kazbour@gmail.com
2015-06-15T20:26:58.548710+00:00 heroku[web.1]: State changed from crashed to starting
2015-06-15T20:26:58.512202+00:00 heroku[slug-compiler]: Slug compilation started
2015-06-15T20:26:58.512230+00:00 heroku[slug-compiler]: Slug compilation finished
2015-06-15T20:27:02.685211+00:00 heroku[web.1]: Starting process with command `node app.js`
2015-06-15T20:27:04.742124+00:00 app[web.1]: Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY)
2015-06-15T20:27:04.742151+00:00 app[web.1]: Recommending WEB_CONCURRENCY=1
2015-06-15T20:27:05.295237+00:00 app[web.1]: module.js:338
2015-06-15T20:27:05.295241+00:00 app[web.1]:     throw err;
2015-06-15T20:27:05.295242+00:00 app[web.1]:           ^
2015-06-15T20:27:05.295244+00:00 app[web.1]: Error: Cannot find module 'express-session'
2015-06-15T20:27:05.295247+00:00 app[web.1]:     at Function.Module._load (module.js:278:25)
2015-06-15T20:27:05.295246+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:336:15)
2015-06-15T20:27:05.295248+00:00 app[web.1]:     at Module.require (module.js:365:17)
2015-06-15T20:27:05.295250+00:00 app[web.1]:     at require (module.js:384:17)
2015-06-15T20:27:05.295251+00:00 app[web.1]:     at Object.<anonymous> (/app/app.js:11:15)
2015-06-15T20:27:05.295253+00:00 app[web.1]:     at Module._compile (module.js:460:26)
2015-06-15T20:27:05.295255+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:478:10)
2015-06-15T20:27:05.295257+00:00 app[web.1]:     at Function.Module._load (module.js:310:12)
2015-06-15T20:27:05.295256+00:00 app[web.1]:     at Module.load (module.js:355:32)
2015-06-15T20:27:05.295259+00:00 app[web.1]:     at Function.Module.runMain (module.js:501:10)
2015-06-15T20:27:06.155893+00:00 heroku[web.1]: State changed from starting to crashed
2015-06-15T20:27:06.156698+00:00 heroku[web.1]: State changed from crashed to starting
2015-06-15T20:27:06.140225+00:00 heroku[web.1]: Process exited with status 1
2015-06-15T20:27:09.292073+00:00 heroku[web.1]: Starting process with command `node app.js`
2015-06-15T20:27:11.100911+00:00 app[web.1]: Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY)
2015-06-15T20:27:11.100933+00:00 app[web.1]: Recommending WEB_CONCURRENCY=1
2015-06-15T20:27:11.975393+00:00 app[web.1]: module.js:338
2015-06-15T20:27:11.975397+00:00 app[web.1]:     throw err;
2015-06-15T20:27:11.975399+00:00 app[web.1]:           ^
2015-06-15T20:27:11.975401+00:00 app[web.1]: Error: Cannot find module 'express-session'
2015-06-15T20:27:11.975402+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:336:15)
2015-06-15T20:27:11.975404+00:00 app[web.1]:     at Function.Module._load (module.js:278:25)
2015-06-15T20:27:11.975405+00:00 app[web.1]:     at Module.require (module.js:365:17)
2015-06-15T20:27:11.975408+00:00 app[web.1]:     at Object.<anonymous> (/app/app.js:11:15)
2015-06-15T20:27:11.975407+00:00 app[web.1]:     at require (module.js:384:17)
2015-06-15T20:27:11.975410+00:00 app[web.1]:     at Module._compile (module.js:460:26)
2015-06-15T20:27:11.975411+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:478:10)
2015-06-15T20:27:11.975412+00:00 app[web.1]:     at Module.load (module.js:355:32)
2015-06-15T20:27:11.975414+00:00 app[web.1]:     at Function.Module._load (module.js:310:12)
2015-06-15T20:27:11.975415+00:00 app[web.1]:     at Function.Module.runMain (module.js:501:10)
2015-06-15T20:27:13.067329+00:00 heroku[web.1]: State changed from starting to crashed
2015-06-15T20:27:13.052249+00:00 heroku[web.1]: Process exited with status 1
2015-06-15T20:27:19.506077+00:00 heroku[api]: Scale to web=1 by c.kazbour@gmail.com
2015-06-15T20:27:46.543780+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=simplifly.herokuapp.com request_id=3df4bc96-feb7-48c6-a52b-ded903ae154e fwd="50.141.68.137" dyno= connect= service= status=503 bytes=
2015-06-15T20:34:06.988969+00:00 heroku[slug-compiler]: Slug compilation started
2015-06-15T20:34:06.988997+00:00 heroku[slug-compiler]: Slug compilation finished
2015-06-15T20:34:06.911574+00:00 heroku[api]: Deploy d8ce9d8 by c.kazbour@gmail.com
2015-06-15T20:34:06.911574+00:00 heroku[api]: Release v5 created by c.kazbour@gmail.com
2015-06-15T20:34:07.186442+00:00 heroku[web.1]: State changed from crashed to starting
2015-06-15T20:34:09.816487+00:00 heroku[web.1]: Starting process with command `node app.js`
2015-06-15T20:34:11.760020+00:00 app[web.1]: Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY)
2015-06-15T20:34:11.760047+00:00 app[web.1]: Recommending WEB_CONCURRENCY=1
2015-06-15T20:34:12.637513+00:00 app[web.1]: I'm listening
2015-06-15T20:34:27.737044+00:00 heroku[api]: Scale to web=1 by c.kazbour@gmail.com
2015-06-15T20:35:10.211701+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2015-06-15T20:35:10.211701+00:00 heroku[web.1]: Stopping process with SIGKILL
2015-06-15T20:35:11.059387+00:00 heroku[web.1]: State changed from starting to crashed
2015-06-15T20:35:11.047891+00:00 heroku[web.1]: Process exited with status 137
2015-06-15T20:35:49.365371+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=simplifly.herokuapp.com request_id=596720e4-470d-4c1b-9beb-88830c2530b4 fwd="50.141.68.137" dyno= connect= service= status=503 bytes=
2015-06-15T20:35:54.100625+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=simplifly.herokuapp.com request_id=3304c0b0-4ea8-4b4c-9b15-68018303143a fwd="50.141.68.137" dyno= connect= service= status=503 bytes=
2015-06-15T20:35:59.738039+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=simplifly.herokuapp.com request_id=f0c96f6c-e017-443b-b3fc-c470ea172b09 fwd="50.141.68.137" dyno= connect= service= status=503 bytes=
2015-06-15T20:35:56.928372+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=simplifly.herokuapp.com request_id=bd37d2d7-4e40-4a83-ae4c-c4bb8d77ebab fwd="50.141.68.137" dyno= connect= service= status=503 bytes=
2015-06-15T20:47:13.464465+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=simplifly.herokuapp.com request_id=11dae041-9755-46f3-8120-62185021f166 fwd="50.141.68.137" dyno= connect= service= status=503 bytes=
2015-06-15T20:50:18.169656+00:00 heroku[api]: Starting process with command `bash` by c.kazbour@gmail.com
2015-06-15T20:50:21.182682+00:00 heroku[run.7063]: Awaiting client
2015-06-15T20:50:21.207522+00:00 heroku[run.7063]: Starting process with command `bash`
2015-06-15T20:50:21.498626+00:00 heroku[run.7063]: State changed from starting to up
2015-06-15T20:56:22.967959+00:00 heroku[run.7063]: Process exited with status 130
2015-06-15T20:56:22.982990+00:00 heroku[run.7063]: State changed from up to complete
2015-06-15T20:56:34.860491+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=simplifly.herokuapp.com request_id=03ab7279-9f54-47f3-bd78-66a1f8878f11 fwd="50.141.68.137" dyno= connect= service= status=503 bytes=
2015-06-15T22:06:06.911203+00:00 heroku[web.1]: State changed from crashed to starting
2015-06-15T22:06:09.190364+00:00 heroku[web.1]: Starting process with command `node app.js`
2015-06-15T22:06:11.192311+00:00 app[web.1]: Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY)
2015-06-15T22:06:11.192332+00:00 app[web.1]: Recommending WEB_CONCURRENCY=1
2015-06-15T22:06:12.342276+00:00 app[web.1]: I'm listening
2015-06-15T22:07:09.670256+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2015-06-15T22:07:09.670341+00:00 heroku[web.1]: Stopping process with SIGKILL
2015-06-15T22:07:10.700825+00:00 heroku[web.1]: State changed from starting to crashed
2015-06-15T22:07:10.687467+00:00 heroku[web.1]: Process exited with status 137
2015-06-15T23:35:04.950903+00:00 heroku[web.1]: State changed from crashed to starting
2015-06-15T23:35:10.538060+00:00 heroku[web.1]: Starting process with command `node app.js`
2015-06-15T23:35:13.112171+00:00 app[web.1]: Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY)
2015-06-15T23:35:13.120415+00:00 app[web.1]: Recommending WEB_CONCURRENCY=1
2015-06-15T23:35:16.100005+00:00 app[web.1]: I'm listening
2015-06-15T23:36:10.835815+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2015-06-15T23:36:10.835815+00:00 heroku[web.1]: Stopping process with SIGKILL
2015-06-15T23:36:11.797436+00:00 heroku[web.1]: Process exited with status 137
2015-06-15T23:36:11.815434+00:00 heroku[web.1]: State changed from starting to crashed
2015-06-16T00:28:50.659338+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=simplifly.herokuapp.com request_id=4412f0e2-1e68-4ec0-9a62-47c3f5151cbb fwd="50.141.68.137" dyno= connect= service= status=503 bytes=
2015-06-16T00:28:55.687612+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=simplifly.herokuapp.com request_id=b3487f82-36f7-4138-9247-30a8a45effd9 fwd="50.141.68.137" dyno= connect= service= status=503 bytes=
2015-06-16T00:28:58.049747+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=simplifly.herokuapp.com request_id=69e2ddf4-9c28-42f5-8aec-47cf51bb4109 fwd="50.141.68.137" dyno= connect= service= status=503 bytes=

我是否在错误地阅读日志文件,而错误实际上出现在其他地方?非常感谢您提供任何正确方向的指针!我已经阅读了教程并搜索了谷歌,但是无法弄清楚。
1个回答

1
将 express-session 添加到 package.json 中解决了我的问题。
"express-session": "1.14.2"

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接