node.js - 将 Node.js 应用程序部署到 Heroku 的问题

标签 node.js heroku heroku-toolbelt

我正在尝试部署一个简单的应用程序,该应用程序是按照 Heroku 在线教程创建的。该应用程序部署正常,但当我打开它时,我收到以下消息:

"An error occurred in the application and your page could not be served. Please try again in a few moments."

在日志中我看到以下内容:

at=error code=H10 desc="App crashed" method=GET path="/" host=testapp.herokuapp.com request_id=245c73e7-1c11-4c98-8bb5-92dee6599ef2 fwd="64.46.7.78" dyno= connect= service= status=503 bytes=

我在网上阅读的有关将 Node.js 应用程序部署到 Heroku 的所有教程都说我需要定义一个 Procfile 并添加如下内容:

web: node server.js

我的应用程序中没有 server.js 文件,那么我应该在此处指定什么文件?是根目录中的 app.js 还是 bin 文件夹中的 www 文件?我真的很困惑...

更新 Procfile 后,我是否需要重新启动 heroku 或重新部署整个应用程序才能生效?

感谢您的帮助!

编辑:

在日志的上方,我看到以下内容:

2016-04-05T01:19:48.266570+00:00 app[web.1]: /app/node_modules/monk/node_modules/mongoskin/lib/utils.js:33
2016-04-05T01:19:48.266584+00:00 app[web.1]:   var skinClassName = 'Skin' + NativeClass.name;
2016-04-05T01:19:48.266585+00:00 app[web.1]:                                           ^
2016-04-05T01:19:48.266586+00:00 app[web.1]:
2016-04-05T01:19:48.266588+00:00 app[web.1]:     at makeSkinClass (/app/node_modules/monk/node_modules/mongoskin/lib/utils.js:33:43)
2016-04-05T01:19:48.266587+00:00 app[web.1]: TypeError: Cannot read property 'name' of undefined
2016-04-05T01:19:48.266589+00:00 app[web.1]:     at Object.<anonymous> (/app/node_modules/monk/node_modules/mongoskin/lib/grid.js:6:35)
2016-04-05T01:19:48.266589+00:00 app[web.1]:     at Module._compile (module.js:413:34)
2016-04-05T01:19:48.266590+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:422:10)
2016-04-05T01:19:48.266591+00:00 app[web.1]:     at Module.load (module.js:357:32)
2016-04-05T01:19:48.266591+00:00 app[web.1]:     at Function.Module._load (module.js:314:12)
2016-04-05T01:19:48.266592+00:00 app[web.1]:     at Module.require (module.js:367:17)
2016-04-05T01:19:48.266592+00:00 app[web.1]:     at require (internal/module.js:16:19)
2016-04-05T01:19:48.266594+00:00 app[web.1]:     at Module._compile (module.js:413:34)
2016-04-05T01:19:48.266593+00:00 app[web.1]:     at Object.<anonymous> (/app/node_modules/monk/node_modules/mongoskin/lib/db.js:22:16)

这就是应用程序触发错误的原因吗?

最佳答案

修复此模块的临时解决方案是将 mongodb@1.4.4 添加为依赖项,因为问题源于 mongoskin(意外地)切换到它不支持的 mongodb@2.X 的对等依赖项。

关于node.js - 将 Node.js 应用程序部署到 Heroku 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36415833/

相关文章:

node.js - Safari 中的快速 session 为空

javascript - 如何从 react 组件进行远程服务器调用?

heroku - Heroku procfile“Procfile中未定义此类进程类型的网络”错误

http - 如何使用 http 而不是 https 在 Heroku 上提供 Golang 应用程序?

ruby-on-rails - 使用 Homebrew 软件安装了 heroku-toolbelt,不包括工头

node.js - MongoDB insertMany 并跳过重复项

node.js - socket.io - 如何在命名空间上广播消息?

android - Heroku 不验证证书请求,为什么?

ruby-on-rails - 从heroku bash在heroku上复制/安装wkhtmltoimage

heroku - 更改密码后 Heroku CLI 中的身份验证失败