Express has no method configure error

前端 未结 2 1734
南旧
南旧 2021-02-04 02:33

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



        
相关标签:
2条回答
  • 2021-02-04 02:42

    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 only
    if ('development' == app.get('env')) {
      app.set('mongodb_uri', 'mongo://localhost/dev');
    }
    
    // production only
    if ('production' == app.get('env')) {
      app.set('mongodb_uri', 'mongo://localhost/prod');
    }
    
    0 讨论(0)
  • 2021-02-04 02:43

    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

    0 讨论(0)
提交回复
热议问题