Debugging 使用intellij调试带有Grunt的项目

Debugging 使用intellij调试带有Grunt的项目,debugging,intellij-idea,gruntjs,Debugging,Intellij Idea,Gruntjs,我使用带有平均堆栈的intellij,我想调试服务器的js文件。 到目前为止,我在项目所在目录的一行命令中启动了“grunt serve”,我没有问题 在intellij中,有两种方法可以使用NodeJ调试项目。您可以使用远程调试配置。这种方法是可行的,但不是很舒服。每次更改js文件时都必须停止调试程序,并且必须重新启动调试程序 或者您可以配置GruntJs配置 我尝试使用这种方式,但我没有从项目目录在终端中启动“grunt服务”时的行为。进程卡在“并发:服务器”上 这是我在intellij中的

我使用带有平均堆栈的intellij,我想调试服务器的js文件。 到目前为止,我在项目所在目录的一行命令中启动了“grunt serve”,我没有问题

在intellij中,有两种方法可以使用NodeJ调试项目。您可以使用远程调试配置。这种方法是可行的,但不是很舒服。每次更改js文件时都必须停止调试程序,并且必须重新启动调试程序

或者您可以配置GruntJs配置

我尝试使用这种方式,但我没有从项目目录在终端中启动“grunt服务”时的行为。进程卡在“并发:服务器”上

这是我在intellij中的配置:

这是intellij生成的行命令

/usr/bin/node --debug-brk=36118 --expose_debug_as=v8debug /home/bryan/Documents/projects/subscriptions/node_modules/grunt/node_modules/grunt-cli/bin/grunt --gruntfile /home/bryan/Documents/projects/subscriptions/subscriptions/Gruntfile.js -v -d serve

所以我的问题是:在终端中使用“grunt服务”或使用intelliJ的grunt调试配置有什么区别?

我从intelliJ支持中找到了这些链接

解决方案:

https://intellij-support.jetbrains.com/hc/en-us/community/posts/206320279-AngularJS-debug-grunt-server-hangs-at-Running-concurrent-server-concurrent-task
说明:

http://stackoverflow.com/questions/19252310/how-to-fork-a-child-process-that-listens-on-a-different-debug-port-than-the-pare
问题可能是由Grunt生成子任务的方式引起的。默认情况下,派生的子进程使用与父进程>进程相同的调试端口-因此分叉的进程被挂起,>应用程序“暂停”。例如,请参见>>that-listens-on-a-different-debug-port-than-the-pare。 请尝试添加process.execArgv=[];在gruntfile.js的顶部 在Gruntfile.js的顶部-它有帮助吗

是的,在GruntFile.js的顶部添加process.execArgv=[]可以删除“concurrent:service”的错误,但是我的断点在端口5858上不起作用

在覆盖process.execArgv之前,以下是内容:

[ '--debug-brk=40305', '--expose_debug_as=v8debug' ]
在“咕噜声发球”开始时,我有以下几点:

/usr/bin/node --debug-brk=40305 --expose_debug_as=v8debug /home/bryan/Documents/projects/subscriptions/node_modules/grunt/node_modules/grunt-cli/bin/grunt --gruntfile /home/bryan/Documents/projects/subscriptions/subscriptions/Gruntfile.js serve
debugger listening on port 40305
Running "serve" task
最后:

Running "express:dev" (express) task
Stopping Express server
Starting background Express server
debugger listening on port 5858
Express server listening on 9000, in development mode
在intellij调试器变量面板中,显示其“连接到本地主机:40305”

当我对端口上的nodejs debug remote使用第二个调试配置时:5858个断点正在工作,但正如我在第一个问题中所描述的,这很难看

我尝试了这个解决方案,但没有任何改变:

https://stackoverflow.com/questions/21957411/debugging-grunt-with-intellij?rq=1
我的gruntfiles已经拥有这些属性:

express: { dev: { options: { script: 'app/server.js', debug: true } } },
这些修改位于文件节点\u modules\grunt express server\tasks\lib\server.js的第71行,将“--debug”更改为“--debug brk=”不会影响调试