【问题标题】:Node.js + socket.io runs locally with foreman but crashes on herokuNode.js + socket.io 使用工头在本地运行,但在 heroku 上崩溃
【发布时间】:2014-09-18 12:20:49
【问题描述】:

在heroku上运行时出现以下错误:

4-07-26T22:24:01.691178+00:00 heroku[web.1]:状态从开始变为崩溃

2014-07-26T22:24:01.692242+00:00 heroku[web.1]: State changed from crashed to starting
2014-07-26T22:24:04.483585+00:00 app[web.1]: 
26)
...
2014-07-26T22:24:04.484066+00:00 app[web.1]:           ^
2014-07-26T22:24:04.485813+00:00 app[web.1]:     at Module.load (module.js:356:32)
2014-07-26T22:24:04.484057+00:00 app[web.1]:     throw err;
2014-07-26T22:24:04.485806+00:00 app[web.1]:     at require (module.js:380:17)
2014-07-26T22:24:04.483677+00:00 app[web.1]: module.js:340
2014-07-26T22:24:04.485808+00:00 app[web.1]:     at Object.<anonymous> (/app/node_modules/socket.io/node_modules/socket.io-parser/node_modules/emitter/index.js:6:13)

如果我使用“heroku labs:enable websockets”,我会得到“没有这样的功能:websockets”

【问题讨论】:

  • 我有同样的错误...似乎对除我们以外的所有人都有效...当我运行“heroku labs:list”时,列表中也没有显示 websockets。
  • 您找到解决方案了吗?你能在 Heroku 上激活 Websocket 吗?我刚刚尝试了heroku lab:enable websockets -a appname,但显示了一条消息:No such feature: websockets。如果您发现解决方案将很高兴知道这一点!谢谢!
  • Heroku 已默认为 7 月 7 日之后创建的所有应用启用 websocket。试试对我有用的解决方案。

标签: node.js heroku socket.io


【解决方案1】:

问题

Heroku 在您的 ../emitter/index.js 中找不到对象。 socket.io 模块的一些文件夹是“gitignored”。 (为什么?)

看起来 websockets 不再是 heroku:labs 功能并且默认启用。我在未启用实验室功能的情况下运行了 socket.io 聊天示例。

快速解决方案

git add -A --force |然后提交并部署

【讨论】:

    猜你喜欢
    • 2012-01-28
    • 2021-08-25
    • 1970-01-01
    • 2020-07-17
    • 2020-12-08
    • 2020-11-30
    • 2013-11-03
    • 1970-01-01
    • 2020-03-16
    相关资源
    最近更新 更多