相关疑难解决方法(0)

Heroku + node.js错误(Web进程在启动后60秒内无法绑定到$ PORT)

我有我的第一个node.js应用程序(本地运行正常) - 但我无法通过heroku(第一次w/heroku)部署它.代码如下.所以我不会写这么多代码,所以我只想说在我的网络中本地运行代码没有问题.

 var http = require('http');
 var fs = require('fs');
 var path = require('path');

 http.createServer(function (request, response) {

    console.log('request starting for ');
    console.log(request);

    var filePath = '.' + request.url;
    if (filePath == './')
        filePath = './index.html';

    console.log(filePath);
    var extname = path.extname(filePath);
    var contentType = 'text/html';
    switch (extname) {
        case '.js':
            contentType = 'text/javascript';
            break;
        case '.css':
            contentType = 'text/css';
            break;
    }

    path.exists(filePath, function(exists) {

        if (exists) {
            fs.readFile(filePath, function(error, content) {
                if (error) {
                    response.writeHead(500);
                    response.end();
                }
                else { …
Run Code Online (Sandbox Code Playgroud)

heroku node.js

408
推荐指数
10
解决办法
17万
查看次数

Heroku Node.js错误R10(引导超时) - > Web进程在启动后60秒内无法绑定到$ PORT

我找到了十几种针对Express应用程序的解决方案,并设置了端口来监听.但我有一个不使用Express的应用程序,实际上并没有听任何东西.在成功运行60秒后,我收到一条Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch消息.我怎么能绕过它?谢谢.

heroku node.js

17
推荐指数
3
解决办法
2万
查看次数

标签 统计

heroku ×2

node.js ×2