在node.js中使用express做博客出错
本人菜鸟,才刚刚开始学习node.js,使用express时遇到错误,
Error: .get() requires callback functions but got a [object Undefined],
index.js中的代码为
module.express = function(app) {
app.get( '/', function (req, res) {
res.render( 'index', {title: '主页' });
});
app.get( '/reg', function (req, res) {
res.render( 'reg', {title: '注册' });
});
app.post( '/reg', function (req, res) {
});
app.get( '/login', function (req, res) {
res.render( 'login', {title: '登录' });
});
app.post( '/login', function (req, res) {
});
app.get( '/post', function (req, res) {
res.render( 'post', {title: '发表' });
});
app.post( '/post', function (req, res) {
});
app.get( '/logout', function (req, res) {
});
};
完整的错误代码为:
lu@lu-QSH4:~/node/blog_old1$ node app
/home/lu/node/blog_old1/node_modules/express/lib/router/index.js:290
throw new Error(msg);
^
Error: .get() requires callback functions but got a [object Undefined]
at /home/lu/node/blog_old1/node_modules/express/lib/router/index.js:290:11
at Array.forEach (native)
at Router.route (/home/lu/node/blog_old1/node_modules/express/lib/router/index.js:286:13)
at Router.(anonymous function) [as get] (/home/lu/node/blog_old1/node_modules/express/lib/router/index.js:308:16)
at Function.app.(anonymous function) [as get] (/home/lu/node/blog_old1/node_modules/express/lib/application.js:412:26)
at Object.<anonymous> (/home/lu/node/blog_old1/app.js:42:5)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
求大神指点一二啊!!要崩溃了-_-||
lgclan
9 years, 1 month ago