VSCode will not stop on breakpoints when first node prcess forks a second

最后都变了- 提交于 2020-01-04 05:29:07

问题


The first issue is that there is some conflict error when you do the following from your app.js file and hit F5 to debug:

var cp = require('child_process'); var node2 = cp.fork('./app_FORK.js');

Error: listen EADDRINUSE :::15838 at Object.exports._errnoException (util.js:856:11)

I had the same issue with VS Community, so I did the following there and it worked: var node2 = cp.fork('./app_FORK.js', [], { execArgv: ['--debug=5859'] });

However, in VS Code, it does not seem to work. I place breakpoints, or try to attach after launching node from the command line and it errors out.


回答1:


You are almost there, you just need to configure your launch.json file in the .vscode folder in order to attach the debugger to the child process.

json { "name": "Attach to Node", "type": "node", "address": "localhost", "port": 5859, }

Just spawn the child process on the correct port (can set above) and use the --debug or --debug-brk argument.



来源:https://stackoverflow.com/questions/35109857/vscode-will-not-stop-on-breakpoints-when-first-node-prcess-forks-a-second

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!