Express js 4.0 is released now and my express 3-app is not working after updating because app.configure()
was removed in the new version.
My Express 3-config looks like this:
// all environments
app.configure(function()
{
app.use(express.static(__dirname + '/public'));
// ...
});
// NODE_ENV=development only
app.configure('development', function()
{
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
// ...
});
// NODE_ENV=production only
app.configure('production', function()
{
app.use(express.errorHandler());
// ...
});
My Question: What is the best practice for configuring an express 4 app depending on the NODE_ENV environment variable?
Express js 4.0 is released now and my express 3-app is not working after updating because app.configure()
was removed in the new version.
My Express 3-config looks like this:
// all environments
app.configure(function()
{
app.use(express.static(__dirname + '/public'));
// ...
});
// NODE_ENV=development only
app.configure('development', function()
{
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
// ...
});
// NODE_ENV=production only
app.configure('production', function()
{
app.use(express.errorHandler());
// ...
});
My Question: What is the best practice for configuring an express 4 app depending on the NODE_ENV environment variable?
Share Improve this question asked Apr 10, 2014 at 12:08 bluelDebluelDe 3958 silver badges17 bronze badges1 Answer
Reset to default 20I suggest if you are making this conversion, you read through the 3.x
to 4.x
conversion guide.
Specifically:
app.configure('development', function() {
// configure stuff here
});
// becomes
var env = process.env.NODE_ENV || 'development';
if ('development' == env) {
// configure stuff here
}