node.js - Node.app - 在本地运行,正确部署但无法工作

标签 node.js heroku deployment

我正在尝试在 heroku 上部署我的 Node 应用程序。

这个应用程序在本地运行良好,并在 heroku 上正确推送。

但是,每当我尝试访问该 URL 时,浏览器都会显示:

An error occurred in the application and your page could not be served. Please try again       in a few moments.
If you are the application owner, check your logs for details

起初,我以为是因为我没有注意我正在监听的端口(我不太了解Heroku如何处理以及端口是否重要)所以我复制了与他们所做的相同的代码他们的入门...:

    port = process.env.PORT || 5000;

server.listen(port, function() {
console.log("Listening on " + port);
});

我的 package.json 非常基础:

   {

"name":"Radiorev",
"version":"0.0.1",
"dependencies":{

    "express":"3.3.5",
    "socket.io":"0.9.16"
}
  }

帮助!

顺便说一句,当我输入 heroku log 时,我的 cmd 工具显示了一些非常难读的东西...零换行符。

最佳答案

1

Heroku 不支持 websockets,所以尝试关闭它

// assuming io is the Socket.IO server object
io.configure(function () { 
  io.set("transports", ["xhr-polling"]); 
  io.set("polling duration", 10); 
});

根据 Using Socket.IO with Node.js on Heroku

2

更新:H14 - 是错误 H14(没有网络进程在运行)

尝试添加具有以下内容的 Procfile:

web:node server.js

关于node.js - Node.app - 在本地运行,正确部署但无法工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18654897/

相关文章:

javascript - 基于流程的编程 js html ui

ruby-on-rails - Heroku Legacy 平台停用。如何迁移?

eclipse - 将 GWT 应用程序部署到 Glassfish 3.0

ruby-on-rails - 多台服务器还是一台服务器中的所有内容?

node.js - Visual Studio 2017 Node.js 异常不起作用

javascript - Mongoose - 保存模型数组并 promise 全部

javascript - Node/ express -错误 : Can't set headers after they are sent

ruby-on-rails - 如何销毁包括:dependent records in other tables的表的所有记录

ruby-on-rails - 如何将我的电子邮件进程/例程放在我的前端服务器之外 (Rails 3.2/devise/sendgrid/heroku)

ruby-on-rails - Capistrano 无法在应用程序部署中定位 Gemfile 错误