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');
完全に機能します。
解決策はありますか?
ありがとう!