How to debug grunt in PHPStorm (WebStorm)

This is a good idea about debugging grunt (like event listener functions) in PHP Storm.

There is Node.js support in the storm, but I'm not sure how to set up debugging options if I would like to debug a grunt task, for example when the file has been modified and the watch task emits it.

+2
source share
3 answers

I am using Windows 7. I found that when I type "grunt" in cmd, it actually starts

node c:\Users\<username>\AppData\Roaming\npm\node_modules\grunt-cli\bin\grunt

So, I introduced the PhpStorm startup / debug configuration Path to Node App JS File = c:\Users\<username>\AppData\Roaming\npm\node_modules\grunt-cli\bin\grunt

Now I put a breakpoint inside module.exports = function (grunt) { ... }and on the toolbar I click the Debug button - the breakpoint works as expected!

( , PhpStorm Run/Debug: http://www.jetbrains.com/phpstorm/webhelp/running-and-debugging-node-js.html)

+5

, , PHPStorm WebStorm Newbies


1) WEBSTORM: Run- > Edit Configurations...

2) [+], Node.js ,

Configuration editor

3) Node.js . , , Java script,

enter image description here

GRUNT

C:\GRUNT-TASKPATH ( , grunt), , gruntfile.js

Javascript "C:\Users\USERNAME\AppData\\npm\ node_modules\grunt-cli\bin\grunt" grunt node, linux/mac

TASKNAME grunt,

4) OK,

5) , - (tasks/taskname.js)

, GRUNT .

+3

Linux, PhpStorm Run/Debug Grunt, , - , Node , in/usr/bin

:

A) "Paht to Node": bin Node, /home/ifraixedes/Apps/ node/bin/node B) "Node parameters" Grunt-cli script, :/home/ifraixedes/Apps/node/lib/node_modules/grunt-cli/bin/grunt C) " ": , Gruntfile.js, , D) " Node JS": grunt, ,

And with these settings, I can execute the PhpStorm debugger as a regular NodeJS application, so I can set breakpoints wherever I need.

+1
source

All Articles