Can anyone point out why am I getting this error when I am trying to run the following code ?
var express = require('express');
var login = require('./routes/login');
var app = express();
//all environments
app.configure(function () {
app.use(express.logger('dev'));
app.use(express.bodyParser());
});
app.post('/loginUser',login.loginUser);
app.listen(3000);
console.log("Listening on port 3000...");
I am using node.js with the express 4.x version.
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. In the examples below you can replace "set" with "use".
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');
}
Express 4.x does not have configure method.
https://github.com/visionmedia/express/wiki/Migrating-from-3.x-to-4.x
Also, it doesn't have express.logger
and express.bodyParser
had been deprecated ages ago.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With