我是node的新手,在一个简单的教程中遇到了这个错误。
我正在OS X 10.8.2上尝试使用CodeRunner和终端运行。我还尝试将我的模块放在node_modules
文件夹中。
我可以看出这是某种连接问题,但我不知道为什么?
events.js:71
throw arguments[1]; // Unhandled 'error' event
^
Error: connect ECONNREFUSED
at errnoException (net.js:770:11)
at Object.afterConnect [as oncomplete] (net.js:761:19)
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();
};
module.exports = makeRequest;
https://c9.io/
上,但是得到了相同的错误。 - ianbrew uninstall node
卸载了它,接着使用brew install node@16
安装了 Node 16。一切都很顺利。可能需要使用brew link --force node@16
命令,但我现在记不清了。 - Joshua Pinter