Requerir archivos en Heroku

I'm having problems deploying a nodejs application to Heroku. Git pushes and it builds and deploys properly but then it crashes.

The crashing seems to be caused by any use of require for my own non-module files, eg: var bla = require("./bla.js");

From the 'heroku run bash' I can also see bizarre behavior when I do a require on one of my own files as well, it spews out garbage into the terminal for several minutes instead of the expected result.

The same application runs fine locally and on other servers.

The exact error message is the always helpful:

node.js:134
        throw e; // process.nextTick error, or 'error' event on first tick

I've made a simple test file to demonstrate the problem:

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);

preguntado el 01 de febrero de 12 a las 04:02

is bla is a folder or a module? did you commit the folder bla? -

It's just a JavaScript file, although the problem affects files in folders too. The files do exist, they're visible from the heroku bash + I can cat them and see they are as expected. Requiring any of the installed modules is working fine. -

do you mind pointing me to the heroku repo -

It's not a public repo but I'll add an example. -

I think I've identified more of the problem. The nodejs project and its files were created in linux, but I'm pushing to heroku from OS X. A file I created in OS X did 'require' correctly. -

1 Respuestas

Problem appears to be the files created on Linux are 'text/x-c' instead of 'text/plain'.

Respondido 01 Feb 12, 08:02

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.