I am trying to debug a Node.JS application on VS Code but, when the terminal opens, I get this message:
Error: listen EADDRINUSE :::5858
My application uses a framework called StrawJS (https://github.com/simonswain/straw) and it starts some different processes at the same time. I think that 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 on breakpoints when first node prcess forks a second) but configure the port on the attach.js file didn't work, 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
}
]}
Thank you!
I had the same issue. If you started the node --debug from CMD, you have to only Attach to Process in your VS Code (if you try to launch it again from VS Code on the same port it will cause an error - this was my mistake).
Define the attach configuration object in launch.json with something like this:
{
"type": "node",
"request": "attach",
"name": "Attach to Process",
"port": 5858
}
choose Attach to Process in the dropdown in the upper left corner and press green play button - Start Debugging.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With