我在将nodejs应用程序部署到Heroku时遇到问题。 Git推动并正确构建和部署,但随后崩溃。
崩溃似乎是由我对自己的非模块文件使用require的原因造成的,例如: var bla = require(“./ bla.js”);
从'heroku run bash'中我也可以看到奇怪的行为,当我对我自己的一个文件执行require时,它会在终端中将垃圾喷出几分钟而不是预期的结果。
同一个应用程序在本地和其他服务器上运行良好。
确切的错误消息总是有用的:
node.js:134
throw e; // process.nextTick error, or 'error' event on first tick
我已经制作了一个简单的测试文件来演示这个问题:
var express = require("express"),
log = require("./analytics/log.js").log;
// if I comment out this line it works, the file does exist within heroku
// and works outside of heroku, but it seems any of my own files being
// require'd will trigger the crash
var app = module.exports = express.createServer();
app.configure(function(){
app.use(express.static(__dirname + "/public"));
app.use(express.methodOverride());
app.use(app.router);
});
app.all("*", function(request, response) {
response.end("bla");
});
app.listen(process.env.PORT || 3000);
答案 0 :(得分:0)
问题似乎是在Linux上创建的文件是'text / x-c'而不是'text / plain'。