-1

私は 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)
4

1 に答える 1

-1

JQTPLの所有者はすぐに更新したくない...悲しい。

https://github.com/coolony/kiwi#express-3x-compatibility同じ構文を使っているらしいKiwiがやってくれました。

それ以外の場合は、これを試すことができます: https://github.com/visionmedia/consolidate.js#express-3x-example

于 2012-08-17T04:50:12.987 に答える