подключить приложение (node.js ) объект — это не функция

#javascript #node.js

#javascript #node.js

Вопрос:

Я получаю сообщение об ошибке при попытке запустить это приложение узла:

app.js:

 var connect = require('connect');

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

log-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();

  }
};
 

Вот ошибка и трассировка:
$ 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)
 

Ответ №1:

Это должно быть

 module.exports
 

не

 module.export