I'm having a problem with Nodejitsu. My app runs perfectly when deployed locally but I've recently been introduced to nodejitsu and I've uploaded my app, database and everything.
However, when I try to deploy my application, I keep getting "Internal Server Error".
When I view the log, it tells me:
Error: No default engine was specified and no extension was provided.
I specified both the viewing engine in the package.json and in the app.js file that is charged with controlling the application.
app.configure('development', function(){
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.static(__dirname + '/public'));
app.use(express.logger('dev'));
app.use(express.bodyParser({uploadDir: './uploads' }));
app.use(express.cookieParser());
app.use(express.session({secret: 'mySecret', cookie: {maxAge: 25920000000}}));
app.use(express.errorHandler());
app.use(passport.initialize());
app.use(passport.session());
app.use(app.router);
});
The package.json is
"engines": {
"node": "0.10.x",
"jade": "0.31.0"
}
As you can see, I'm clearly setting up the view engine but I don't understand why the am getting that error. I've also scanned the lib/views.js file for the line that threw the error
if (!ext && !this.defaultEngine) throw new Error('No default engine was specified and no extension was provided.');
Which makes sense when you think of why the error was thrown; however, becomes confusing when I know for certain that I specified a viewing engine.
Ah, omit the
app.configure
wrapper entirely. Just take the code inside it and have it be top-level. Nodejitsu is running your app withNODE_ENV=production
, not development. In general, any configuration that should always be run, such as all of your code above should NOT be put in anapp.configure
callback. I never useapp.configure
at all as it is so trivial to be basically useless, but it's purpose is for things that differ between development and production environments.