gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 02:59:46 25 4
gpt4 key购买 nike

当我尝试运行此 Node 应用程序时出现错误:

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)

最佳答案

应该是这样

module.exports

不是

module.export

关于javascript - 连接应用程序(node.js)对象不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7961890/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com