var express = require('express'); var app = express(); var middleware = { requireAuthentication: function(req,res,next){ console.log("private route hit"); next(); } }; app.use(middleware.requireAuthentication()); app.get('/about',function(req,res){ res.send('You clicked on about!'); } ); var projectDir = __dirname + '/public'; app.use(express.static(projectDir)); app.listen(3000),function(){ console.log('Static service started'); };
我得到错误(当试图运行服务器时)next()不是一个函数.我一直在关注Nodejs的教程,它对他们来说效果很好.我在这有什么问题?