调用函数时出现错误render
[此应用在 Heroku 上运行]
web.js:
var async = require('async');
var express = require('express');
var util = require('util');
// create an express webserver
var app = express.createServer(
express.logger(),
express.static(__dirname + '/public'),
express.bodyParser(),
express.cookieParser(),
// set this to a secret value to encrypt session cookies
express.session({ secret: process.env.SESSION_SECRET || 'secret123' }),
);
app.set('views', __dirname + 'views');
app.set('view engine', 'jade');
// listen to the PORT given to us in the environment
var port = process.env.PORT || 3000;
app.listen(port, function() {
console.log("Listening on " + port);
});
app.get('/', function ( req, res ) {
res.render('ok', { title : 'ok' });
});
好的。玉:
!!! 5
html(lang='en')
head
title= title
body
div#navigation
包.json:
{
"name": "package",
"version": "0.0.1",
"description": "Facebook integration, Node.js",
"dependencies": {
"express": "latest",
"jade":"0.17.0"
},
"engines": {
"node": "0.8.19",
"npm" : "1.2.10"
}
}
错误:
TypeError: Cannot read property '0' of undefined
at new View (/app/node_modules/express/lib/view.js:41:65)
at Function.app.render (/app/node_modules/express/lib/application.js:486:12)
at ServerResponse.res.render (/app/node_modules/express/lib/response.js:753:7)
at /app/web.js:32:9
at callbacks (/app/node_modules/express/lib/router/index.js:161:37)
at param (/app/node_modules/express/lib/router/index.js:135:11)
at pass (/app/node_modules/express/lib/router/index.js:142:5)
at Router._dispatch (/app/node_modules/express/lib/router/index.js:170:5)
at Object.router (/app/node_modules/express/lib/router/index.js:33:10)
at next (/app/node_modules/express/node_modules/connect/lib/proto.js:199:15)
如果我替换res.render('ok', {title : 'ok'});
为res.end('some text');
完美。
有什么解决办法吗?
谢谢!