ruby-on-rails - 错误: Cannot find module 'express-session' when deploying to Heroku

标签 ruby-on-rails node.js heroku express dependencies

我是初学者,我正在尝试将我的 Node 应用程序部署到 Heroku。 根据我在下面的日志中的理解,Heroku 无法读取 Express-Session 依赖项。 所以我检查了我的 package.json 文件,它并不在那里,尽管它在我的 app.js 文件中“需要”它。在没有 Express-Session 的情况下,它也可以在本地使用 Nodemon 正常运行。

假设这可能会导致错误消息,我在依赖项中添加了“express-session”。 然后我在 CL 中运行 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=

我读取的日志文件是否错误并且错误在其他地方?非常感谢您提供正确方向的指示!我一直在阅读教程并用谷歌搜索,但无法弄清楚。

最佳答案

将express-session添加到package.json解决了我的问题。

"express-session": "1.14.2"

关于ruby-on-rails - 错误: Cannot find module 'express-session' when deploying to Heroku,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30857233/

相关文章:

ruby-on-rails - Rails中非模型字段上的错误

node.js - 使用nodejs流gzip压缩文件会导致内存泄漏

node.js - 在 Heroku 上运行 Node.js 应用程序时出错

java - heroku 上的 RESTful java web 服务?

ruby-on-rails - Phusion passenger - 安装后我要做什么?

mysql - 将 LIMMYSQL.dll 从 MySql 复制到 Ruby bin 文件夹时出现 Rails 服务器错误

ruby-on-rails - 没有给定 yield 的 block

javascript - 在套接字 io 上使用 Node 请求库时出错

node.js - 将 morgan 与 logger 一起使用时,stream.write 不是函数

tomcat - 如何将 .war 文件和 jni 库文件部署到 Web 服务器上?