这段代码:
var app = require('express').createServer();
var ejs = require('ejs');
var fs = require('fs');
var indexTemplate = fs.readFileSync(__dirname + '/templates/index.html');
app.get('/', function(req, res){
res.end(ejs.render(indexTemplate, {}));
});
给我以下错误
TypeError:对象地址在 /home/lowerkey/node_modules/ejs/lib/ejs.js 的 Object.parse (/home/lowerkey/node_modules/ejs/lib/ejs.js:152:20) 处没有方法“substr”: 192:13 在 Object.render (/home/lowerkey/node_modules/ejs/lib/ejs.js:235:10) 在 /home/lowerkey/workspace/address book/server/server.js:60:14 在回调 ( /home/lowerkey/node_modules/express/lib/router/index.js:272:11) 在 param (/home/lowerkey/node_modules/express/lib/router/index.js:246:11) 在 pass (/home /lowerkey/node_modules/express/lib/router/index.js:253:5) 在 Router._dispatch (/home/lowerkey/node_modules/express/lib/router/index.js:280:4) 在 Object.handle ( /home/lowerkey/node_modules/express/lib/router/index.js:45:10)在下一个(/home/lowerkey/node_modules/express/node_modules/connect/lib/http.js:203:15)
我究竟做错了什么?