I am quite sure it is really a dummy question for more experienced programmers but I can't figure out how to fix it. Well, the message clear says I am using some deprecated library so it is expected I upgrade it. As far as I can see, this message is related to routing functionality but I can't find how to change from "express.Router()" to some use of "require('path-to-regexp')". Am I confused on the purpose of such message? If not, how to fix the program below in order to not get such "deprecated" warning? As far as I understand, the code below is 100% compliance and updated with NOdeJs Express version 4.
PS.: I am using debian and if I type nodejs --version I get: v4.2.6
server.js:
var router = express.Router();
var index = require('./routes/index').router;
app.use('/',index);
var server = app.listen(3000,function(){
});
index.js:
var express = require('express');
var router = express.Router();
router.get('/',function(req,res){
res.send("Welcome to Node JS");
});
router.get('/about',function(req,res){
res.send("This is About page");
});
var api = router.route('/api/v1/user');
api.all(function(req,res,next){
console.log(req.method,req.url);
next();
});
...
//this line is the Master
module.exports.router = router;
The problem is with your express package. Updating the express module will do the trick.
npm update express --save
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.