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