admin管理员组文章数量:1130349
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.
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.
Share Improve this question asked Mar 8, 2014 at 4:44 msrameshpmsrameshp 6362 gold badges13 silver badges33 bronze badges 1 |2 Answers
Reset to default 10Tom 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.
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.
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.
Share Improve this question asked Mar 8, 2014 at 4:44 msrameshpmsrameshp 6362 gold badges13 silver badges33 bronze badges 1-
1
express 4.x version is completely different from the older versions. So all posts about express will send you in the wrong direction. I would suggest that you stick with an older version for now.
npm install [email protected]– Mukesh Soni Commented Mar 8, 2014 at 4:52
2 Answers
Reset to default 10Tom 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.
本文标签:
版权声明:本文标题:javascript - TypeError: Object function (req, res, next) { app.handle(req, res, next); } has no method 'configure 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1739381409a1648130.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


npm install [email protected]– Mukesh Soni Commented Mar 8, 2014 at 4:52