Reputation: 27
i am new in node.js and encountered a problem in my first code:===>
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('Hello World!');
}).listen(8080);
it throws this error:=====>>
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)
Can anyone please help me
Upvotes: 1
Views: 58
Reputation: 27
well if anyone ever encounters this problem, open your node command prompt and install http-server like this: npm install http-server -g
atleast mine worked by applying this method.
Upvotes: 0
Reputation: 995
The error Error: listen EADDRINUSE :::8080
means that some other process is already using port 8080. Switch your port and try again.
Upvotes: 3