不知道我在做什么错在这里?我的简单node.js函数有什么问题?
错误:
/Users/user/node/app.js:3
makeRequest("Here's looking at you, kid");
^
TypeError: object is not a function
at Object.<anonymous> (/Users/user/node/app.js:3:1)
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)
app.js
var makeRequest = require('./make_request');
makeRequest("Here's looking at you, kid");
makeRequest("Hello, this is dog");
make_request.js
var http = require('http');
var makeRequest = function(message) {
//var message = "Here's looking at you, kid.";
var options = {
host: 'localhost', port:8080, path: '/', method: 'POST'
}
var request = http.request(options, function(response) {
response.on('data', function(data) {
console.log(data);
});
});
request.write(message);
request.end();
};
exports = makeRequest;
更好但仍然:' events.js:71 throw arguments [1]; //未处理 '错误' 事件 ^ 错误:在errnoException连接ECONNREFUSED (net.js:770:11) 在Object.afterConnect [按的onComplete](net.js:761:19)' – ian
试过那些但类似错误:'events.js:71 throw arguments [1]; //未处理 '错误' 事件 ^ 错误:的getaddrinfo ENOENT 在errnoException(dns.js:31:11) 在Object.onanswer [按的onComplete](dns.js:123:16)' – ian
我不真正了解。这是我试图做的'node.js'教程,所以我对它非常基本。尽管如此,它看起来像是某种地址错误。 – ian