Starting of with node js and I thought it would be a good idea to debug the application.
Im running node js on my ubuntu virtual machine.
This is the node script
var http = require('http');
var port = 8080;
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('hello world!');
}).listen(port, '192.168.137.2');
And then I start with the node-inspector.
node-debug index.js
The chrome browser fires up and instantly breaks on first line.
var http = require('http');
Then as I resume the program I get the following error message in the console.
Error: listen EADDRINUSE
at errnoException (net.js:904:11)
at Server._listen2 (net.js:1042:14)
at listen (net.js:1064:10)
at net.js:1146:9
at exports.lookup.callback (dns.js:72:18)
at process._tickCallback (node.js:419:13)
at Module.runMain [as _onTimeout] (module.js:499:11)
at Timer.listOnTimeout [as ontimeout] (timers.js:112:15)
What am I doing wrong?
Everything works fine when I just run
node --debug index.js
But if I do that I dont know how to debug it..
Tried changing port like Simone-Cu said. And that worked..
var port = 8081;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.