Skip to content Skip to sidebar Skip to footer

Express Has No Method Configure Error

I'm trying to get started with the MEAN stack. And I'm following this tutorial: link I have made it until the Test Our Server section. Here // modules ============================

Solution 1:

Tom in his blog post new-features-node-express-4 provides examples of how to convert from using app.configure in express version 3.x to removing it in express version 4.0.

For convenience I added the code example below.

Version 3.x

// all environments
app.configure(function(){
  app.set('title', 'Application Title');
})

// development only
app.configure('development', function(){
  app.set('mongodb_uri', 'mongo://localhost/dev');
})

// production only
app.configure('production', function(){
  app.set('mongodb_uri', 'mongo://localhost/prod');
})

Version 4.0

// all environments
app.set('title', 'Application Title');

// development onlyif ('development' == app.get('env')) {
  app.set('mongodb_uri', 'mongo://localhost/dev');
}

// production onlyif ('production' == app.get('env')) {
  app.set('mongodb_uri', 'mongo://localhost/prod');
}

Solution 2:

The configure method has been removed from express as of version 4.0.0 (including 4.0.0-rc2). See the changelog at https://github.com/strongloop/express/blob/master/History.md#400--2014-04-09

Post a Comment for "Express Has No Method Configure Error"