0

将 Node v0.8.8 与 Express ~3.0.0rc3 一起使用(作为记录,这是我的 packages.json 的内容):

{
  "name": "application-name",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node app"
  },
  "dependencies": {
    "express": "~3.0.0rc3",
    "jade": "*",
    "ejs": "~0.8.2",
    "express-partials": "0.0.5",
    "connect-flash": "~0.1.0",
    "connect-redis": "~1.4.1",
    "validator": "~0.4.11",
    "express-validator": "~0.2.4",
    "express-form": "~0.6.2"
  }
}

并且在尝试执行 POST 以验证登录表单时出现以下错误。

TypeError: Object #<ServerResponse> has no method 'local'
    at /Users/nblavoie/Documents/projets/erphdfnode/node_modules/express-form/lib/form.js:32:15
    at callbacks (/Users/nblavoie/Documents/projets/erphdfnode/node_modules/express/lib/router/index.js:165:11)
    at param...

我的控制器有问题吗?这是代码:

var routes = function(app)
{
    var form = require("express-form"),
        field = form.field;

    app.post("/login",
        form(
            field("courriel").trim().isEmail(),
            field("password").trim().notEmpty()
        ),
        function(req, res)
        {
            if (!req.form.isValid) {
                renderLogin("Courriel ou de mot de passe incorrect.", req);
            } else {
                console.log("OK!!!!!");
            }
        }
    );
};
4

1 回答 1

0

express-form不支持express3.0。

查看此问题以获取更多信息。

于 2012-08-29T07:57:56.120 回答