我有以下代码作为 app.js 的一部分,今天我将 Express 从 2.x 升级到 3.x,之后我更改了文件中的一些代码。我的部分代码仍然无法正常工作。我使用 JQTPL 作为模板引擎。
var express = require ('express');
var login = require ('./modules/login');
var config = require ('config');
var app = module.exports = express();
var server = require('http').createServer(app) ;
app.configure(function(){
app.set("view engine", "html");
app.register(".html", require("jqtpl").express);
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
});
server.listen (config.server.port , function ()
{
console.log ('Server started and listening ' + config.server.port);
});
我得到的错误是
app.register(".html", require("jqtpl").express);
^
TypeError: Object function app(req, res){ app.handle(req, res); } has no method 'register'
at Function.<anonymous> (/home/siva/Work/Applications/TestApp/Explore/TestJQ/app.js:11:9)
at Function.app.configure (/home/siva/node_modules/express/lib/application.js:399:61)
at Object.<anonymous> (/home/siva/Work/Applications/TestApp/Explore/TestJQ/app.js:8:5)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)