Quantcast
Channel: CNode:Node.js专业中文社区
Viewing all articles
Browse latest Browse all 14821

node+express throw new Error('callback function required');

$
0
0

var express = require(‘express’);

var app= express();

//设置handlebars视图引擎 var handlebars = require(‘express3-handlebars’) handlebars.create({defaultLayout:‘main’}); app.engine(‘handlebars’,handlebars.engine); app.set(‘view engine’,‘handlebars’);

app.set(‘port’,process.env.PORT||3000); app.use(express.static(__dirname + ‘/public’));

app.get(’/’,function(req,res){ res.render(‘home’); });

app.get(’/about’,function(req,res){ res.render(‘about’); })

//404 page catch-all处理器(中间件) app.use(function(req,res){ res.status(404); res.render(‘404’); });

//500 page 错误处理器中间件 app.use(function(err,req,res,next){ console.log(err.stack); //express的res.set和res.status()方法替换node的res.writeHead()方法 res.status(500); res.render(‘500’); });

app.listen(app.get(‘port’),function(){ console.log(‘express start on http://localhost:’ + app.get(‘port’) + ‘;press Ctrl-C to terminate’); });

FastStoneEditor.jpg

这里抛出不能请求回调是什么意思?请问怎么解决?谢谢


Viewing all articles
Browse latest Browse all 14821

Trending Articles