U
U
Umid2017-01-24 21:45:08
Node.js
Umid, 2017-01-24 21:45:08

Cannot read property 'handle' of undefined, why?

var express = require('express'),
  http = require('http'),
  path = require('path');

var config = require('./config/'),
  log = require('./libs/log')(module);

var app = express();
app.set('views', __dirname + '/templates');
app.set('view engine', 'jade');

app.use(express.favicon());
if(app.get('env') == 'development') {
  app.use(express.logger('dev'));
} else {
  app.use(express.logger('default'));
}
app.use(express.bodyParser()); // req.body.....
app.use(express.cookieParser()); //req.cookies
app.use(express.router);
app.get('/', function(req, res, next) {
  res.end('Test');
});
app.use(express.static(path.join(__dirname, 'public')));




////////////////////////////////////////////////////////
http.createServer(app).listen(config.get('port'), function() {
  log.info('Express server listening on port ' + config.get('port'));
});

// Middleware
app.use(function(req, res) {
  res.send(404, 'Page not found');
});

app.use(function(err, req, res, next) {
  if(app.get('env') == 'development') {
    var errorHandler = express.errorHandler();
    errorHandler(err);
  }
})

Error on line 20. Those. app.use(express.router);
How can the error be corrected?
909cfc780fd4497da9ee9bcf63992f7d.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
tex0, 2017-01-24
@DarCKoder

maybe after all app.router , not express.router ?
Configuration

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question