Debugging Node.JS by EADDRINUSE code

I am trying to debug a Node.JS application in VS Code, but when the terminal opens, I get this message:

Error: listen to EADDRINUSE: 5858

My application uses the StrawJS framework ( https://github.com/simonswain/straw ) and it starts several different processes at the same time. I think this is the cause of the error, because there are many different processes trying to use the same debugger.

I found a similar question ( VSCode will not stop at breakpoints when the first node prcess calls the second ), but configure the port in the attach.js didn file. The problem persists.

This is my actual launch.json file:

{ "version": "0.2.0", "configurations": [ { "name": "Launch", "type": "node", "request": "launch", "port": 5858, "program": "${workspaceRoot}/run.js", "stopOnEntry": false, "args": [], "cwd": "${workspaceRoot}", "preLaunchTask": null, "runtimeExecutable": null, "runtimeArgs": [ "--nolazy" ], "env": { "NODE_ENV": "development" }, "externalConsole": true, "sourceMaps": false, "outDir": null } ]} 

Thanks!

+7
javascript visual-studio-code
source share
1 answer

I had the same problem. If you started node --debug from CMD, you should only connect to the process in your VS code (if you try to run it again from VS code on the same port, it will cause an error - that was my mistake).

Define the attach configuration object in the launch.json file like this:

 { "type": "node", "request": "attach", "name": "Attach to Process", "port": 5858 } 

select "Attach to process" in the drop-down list in the upper left corner and click the green play button - "Start debugging".

+1
source share

All Articles