使用 intellij 调试带有 Grunt 的项目
Using intellij to debug a project with Grunt
我使用带有平均堆栈的 intellij,我想调试我服务器的 js 文件。
到现在为止,我从我的项目所在的目录中的一行命令中启动 "grunt serve",我没有问题。
在 intellij 中,有两种方法可以使用 nodejs 调试项目。您可以使用远程调试配置。这种方式有效但不是很舒服。每次更改 js 文件时都必须停止调试器,并且必须重新启动调试器....
或者你可以配置一个 GruntJs 配置。
我尝试使用这种方式,但我的行为与我在终端中从项目目录启动 "grunt serve" 时的行为不同。进程卡在 "concurrent:server".
这是我在 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 serve" 或使用来自 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
解释:
The problem is likely caused by the way Grunt spawns child tasks. By >default, the spawned child process uses the same debug port as a parent >process - as a result the forked process is suspended and the >application 'stalls'. See >>that-listens-on-a-different-debug-port-than-the-pare, for example.
Please try adding process.execArgv = []; at the top of the gruntfile.js
at the top of your Gruntfile.js - does it help?
是的,在 GruntFile.js 的顶部添加 process.execArgv = [] 移除了 "concurrent:serve" 的卡住,但我的断点在 port:5858[=18 上不起作用=]
在覆盖之前 process.execArgv 这里是内容:
[ '--debug-brk=40305', '--expose_debug_as=v8debug' ]
在 "grunt serve" 的开头我有这个 :
/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 调试器变量面板中显示 "Connected to localhost:40305"
当我在端口 :5858 上使用带有 nodejs 远程调试的第二个调试配置时,断点正在工作,但这很丑陋,正如我在第一个问题中所描述的那样。
我试过这个解决方案,但没有任何变化:
我的 gruntfiles 已经拥有这些属性:
express: { dev: { options: { script: 'app/server.js', debug: true } } },
以及此文件第 71 行的这些修改 node_modules\grunt-express-server\tasks\lib\server.js,将“--debug”更改为“--debug-brk=”不影响调试。
我使用带有平均堆栈的 intellij,我想调试我服务器的 js 文件。 到现在为止,我从我的项目所在的目录中的一行命令中启动 "grunt serve",我没有问题。
在 intellij 中,有两种方法可以使用 nodejs 调试项目。您可以使用远程调试配置。这种方式有效但不是很舒服。每次更改 js 文件时都必须停止调试器,并且必须重新启动调试器....
或者你可以配置一个 GruntJs 配置。
我尝试使用这种方式,但我的行为与我在终端中从项目目录启动 "grunt serve" 时的行为不同。进程卡在 "concurrent:server".
这是我在 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 serve" 或使用来自 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
解释:
The problem is likely caused by the way Grunt spawns child tasks. By >default, the spawned child process uses the same debug port as a parent >process - as a result the forked process is suspended and the >application 'stalls'. See >>that-listens-on-a-different-debug-port-than-the-pare, for example. Please try adding process.execArgv = []; at the top of the gruntfile.js at the top of your Gruntfile.js - does it help?
是的,在 GruntFile.js 的顶部添加 process.execArgv = [] 移除了 "concurrent:serve" 的卡住,但我的断点在 port:5858[=18 上不起作用=]
在覆盖之前 process.execArgv 这里是内容:
[ '--debug-brk=40305', '--expose_debug_as=v8debug' ]
在 "grunt serve" 的开头我有这个 :
/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 调试器变量面板中显示 "Connected to localhost:40305"
当我在端口 :5858 上使用带有 nodejs 远程调试的第二个调试配置时,断点正在工作,但这很丑陋,正如我在第一个问题中所描述的那样。
我试过这个解决方案,但没有任何变化:
我的 gruntfiles 已经拥有这些属性:
express: { dev: { options: { script: 'app/server.js', debug: true } } },
以及此文件第 71 行的这些修改 node_modules\grunt-express-server\tasks\lib\server.js,将“--debug”更改为“--debug-brk=”不影响调试。