Nodejs服务器ging错误:TypeError:对象#的属性'engine'不是函数

时间:2012-12-06 12:30:17

标签: node.js typeerror express jst

我正在尝试启动此NodeJS Server,但我收到了一条TypeError消息,我已将Express更新为最新版本。我认为JST还没有使用express 3,但是我无法找到是否是这种情况或者我的代码是错误的。我的代码如下:

**Express 500 
TypeError: Property 'engine' of object #<View> is not a function**

at View.render (C:\wip\node_modules\express\lib\view.js:75:8)
at Function.app.render (C:\wip\node_modules\express\lib\application.js:501:10)
at ServerResponse.res.render (C:\wip\node_modules\express\lib\response.js:719:7)
at C:\wip\server.js:40:7
at callbacks (C:\wip\node_modules\express\lib\router\index.js:160:37)
at param (C:\wip\node_modules\express\lib\router\index.js:134:11)
at pass (C:\wip\node_modules\express\lib\router\index.js:141:5)
at Router._dispatch (C:\wip\node_modules\express\lib\router\index.js:169:5)
at Object.router (C:\wip\node_modules\express\lib\router\index.js:32:10)
at next (C:\wip\node_modules\express\node_modules\connect\lib\proto.js:190:15)


var express = require('express'),
jst = require('jst'),
locales = require('locales');

var app = express();

// Configuration
locales.configure({ locales: __dirname + '/locales' });

app.configure(function(){
    app.set('views', __dirname + '/views');
    app.set('view engine', 'jst');
    app.use(express.bodyParser());
    app.use(express.methodOverride());
    app.use(function(req, res, next) { req.lang = 'en'; next(); });
    app.use(locales.detector); // for i18n
    app.use(app.router);
    app.use(express.static(__dirname + '/public'));
});

app.configure('development', function(){
    app.use(express.errorHandler({ dumpExceptions: true, showStack: true })); 
});

app.configure('production', function(){
    app.use(express.errorHandler()); 
});

// Routes
app.get('/', function(req, res){
    res.render('index', {
    title: 'Express'
    });
});

if (!module.parent) { app.listen(3000); console.log("Express server running"); }

1 个答案:

答案 0 :(得分:0)

我发现JUST不支持Express 3x。 所以我正在转向像HBS这样的另一个模板引擎。