当第一个节点处理分叉时,VSCode不会在断点处停止 [英] VSCode will not stop on breakpoints when first node prcess forks a second

查看:193
本文介绍了当第一个节点处理分叉时,VSCode不会在断点处停止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

第一个问题是,当您从app.js文件执行以下操作并按F5键进行调试时,会出现一些冲突错误:

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');

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

错误:在对象处监听EADDRINUSE ::: 15838
。 exports._errnoException(util.js:856:11)

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

我在VS社区遇到了同样的问题,因此我在其中执行了以下操作,并且有效:
var node2 = cp.fork('./ app_FORK.js',[],{execArgv:['--debug = 5859']});

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'] });

不过,在VS Code中,它似乎不起作用。我放置了断点,或者尝试从命令行启动节点之后尝试附加它,并且出错了。

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.

推荐答案

您快到了,您只需在.vscode文件夹中配置launch.json文件,即可将调试器附加到子进程。

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:附加到节点, type:节点, address:本地主机, port:5859,}

只需在正确的端口(可以在上面设置)上生成子进程,并使用--debug或--debug-brk参数即可。

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

这篇关于当第一个节点处理分叉时,VSCode不会在断点处停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆