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 + './template');
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(app.router);
app.get('/', function(req, res, next) {
res.render("index", {})
});
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);
}
})
в jade у меня лишь
5
h1= hello world
На странице и в консоли выводится следующее:
TypeError: Cannot read property 'statusCode' of undefined
at errorHandler (C:\Users\Umid\node_modules\express\node_modules\connect\lib\middleware\errorHandler.js:47:12)
at Object.handle (C:\Users\Umid\Desktop\ExpressProjects\firstApp\app.js:43:3)
at next (C:\Users\Umid\node_modules\express\node_modules\connect\lib\proto.js:185:17)
at next (C:\Users\Umid\node_modules\express\node_modules\connect\lib\proto.js:187:11)
at next (C:\Users\Umid\node_modules\express\node_modules\connect\lib\proto.js:187:11)
at pass (C:\Users\Umid\node_modules\express\lib\router\index.js:110:24)
at nextRoute (C:\Users\Umid\node_modules\express\lib\router\index.js:100:7)
at callbacks (C:\Users\Umid\node_modules\express\lib\router\index.js:167:11)
at callbacks (C:\Users\Umid\node_modules\express\lib\router\index.js:170:9)
at param (C:\Users\Umid\node_modules\express\lib\router\index.js:138:11)
Заманался уже искать решение. Прошу помочь.