This can be done by running node-inspector and running grunt in debug mode. After that, you can go through Gruntfile.js in Chrome, as usual.
start node inspector
If you don't already have node-inspector , install it using npm install -g node-inspector . Then run it in one terminal / command line:
$ node-inspector Node Inspector v0.7.3 Visit http://127.0.0.1:8080/debug?port=5858 to start debugging.
run grunt in debug mode
Then find the grunt script. This is the javascript file that is executed when the grunt command is run from the command line. If you installed grunt all over the world (using npm install -g grunt-cli ), then it will most likely be located in /usr/bin or /usr/local/bin for * nix or Mac machines. For Windows machines, the grunt.cmd file indicates where the grunt script is located. Most likely, the grunt script is located in C:\Users\<username>\AppData\Roaming\npm\node_modules\grunt-cli\bin .
After you find the location of the script, use node --debug-brk to execute this script, thereby running grunt in debug mode, breaking the first line of code in the file. For example, suppose the grunt script is located in /usr/bin/grunt :
$ node --debug-brk /usr/bin/grunt debugger listening on port 5858
You will find out that you have succeeded when you see debugger listening on port 5858 as the output, which means that the grunt script has stopped execution and expects that the transition with the debugger will be completed.
debugging with chrome
Now pick up Chrome and point it to http://127.0.0.1:8080/debug?port=5858 . In Chrome, open and add breakpoints in Gruntfile.js and complete the step as usual.
source share