简体   繁体   English

连接应用程序(node.js)对象不是函数

[英]connect app (node.js) object is not a function

I get an error when I try to run this node app: 尝试运行此节点应用程序时出现错误:

app.js: app.js:

var connect = require('connect');

connect.createServer(
  require('./log-it')(),
  require('./serve-js')()
).listen(4000);

log-it.js: 登录it.js:

var util = require('util');

module.export = function()
{

  var counter = 0;


  return function(req, res, next) {
    var writeHead = res.writeHead;

    counter ++;

    res.writeHead = function(code, headers) {
      res.writeHead = writeHead;
      console.log("Response #" + counter + ": " + code + ' ' + util.inspect(head));
    }

    next();

  }
};

Here's the error and traceback: $ node app.js 错误和回溯如下:$ node app.js

node.js:134
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
TypeError: object is not a function
    at Object.CALL_NON_FUNCTION (native)
    at Object.<anonymous> (/Users/me/projects/Share/web/app.js:4:21)
    at Module._compile (module.js:407:26)
    at Object..js (module.js:413:10)
    at Module.load (module.js:339:31)
    at Function._load (module.js:298:12)
    at Array.<anonymous> (module.js:426:10)
    at EventEmitter._tickCallback (node.js:126:26)

That should be 那应该是

module.exports

not

module.export

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM