什么阻止我的node.js代码? 从命令行中引用一个参数

我试图把第一个命令行参数作为运行节点上的端口。 以下代码在node.js中不起作用:

try { if(process.argv[2] == undefined) { throw new Error("no port specified"); } var port = process.argv[0]; console.log(port); } catch (err) { console.log("Error give port number as the argument"); return; } require('http').createServer(function handleRequest(req, res) { res.writeHead(200, {'content-type' : 'text/plain'}); res.end('Hello World!'); }).listen(port); 

它给出了以下错误:

 $ node server.js 8080 node events.js:72 throw er; // Unhandled 'error' event ^ Error: listen EADDRINUSE at errnoException (net.js:884:11) at Server._listen2 (net.js:1003:19) at listen (net.js:1044:10) at Server.listen (net.js:1104:5) at Object.<anonymous> (/home/studiet/Documents/Aptana Studio 3 Workspace/nodef2b/server.js:19:4) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10) 

我知道node.js是asynchronous的,但在这种情况下,我认为没有什么东西在等待什么。 哪里不对? 我该如何让这个系统在这里等待太久,什么时间太长? 或者,还有什么错误?

编辑:第19行代码是我.listen(端口);

EADDRINUSE代表错误地址在使用中。

其他一些进程正在使用端口80。

你需要find这个过程,并以极端的偏见终止它。

编辑 :在这种情况下,这意味着一个无效的端口号。
正如你可以从你的输出的第一行看到的, port"node" ,而不是8080
您需要将其设置为argv[2]