我是 node.js 的新手,在我的第一个代码中遇到了一个问题:===>
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('Hello World!');
}).listen(8080);
它抛出这个错误:=====>>
events.js:182
throw er; // Unhandled 'error' event
^ Error: listen EADDRINUSE :::8080
at Object._errnoException (util.js:1041:11)
at _exceptionWithHostPort (util.js:1064:20)
at Server.setupListenHandle [as _listen2] (net.js:1322:14)
at listenInCluster (net.js:1370:12)
at Server.listen (net.js:1466:7)
at Object.<anonymous> (C:\Users\Tuladhar\nodeJS.js:6:4)
at Module._compile (module.js:573:30)
at Object.Module._extensions..js (module.js:584:10)
at Module.load (module.js:507:32)
at tryModuleLoad (module.js:470:12)
谁能帮帮我
最佳答案
错误 Error: listen EADDRINUSE:::8080
意味着其他一些进程已经在使用端口 8080。切换您的端口并重试。
关于javascript - 在我的第一个 node.js 代码中遇到问题,我不明白哪里出了问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46355695/