Answer the question
In order to leave comments, you need to log in
Why can't render .jade (Error is thrown)?
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);
}
})
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)
Answer the question
In order to leave comments, you need to log in
doctype html
html(lang="ru")
head
meta(charset="UTF-8")
title Заголовок страницы
body
h1 Hello, world!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question