So I have spent the past couple days trying to get this to work with no luck. Most of the solutions I have found seem to work "okay" for debugging node applications. But I haven't had much luck debugging grunt stand alone. I would like to be able to set breakpoints in my gruntfile and either step through the code with either the browser or an IDE.
I have tried the following:
node --debug-brk Gruntfile.js
#!/usr/bin/env node --debug-brk
node-inspector C:\path\to\gruntfile grunt
Node Inspector v0.7.3
Visit http://localhost:8080/debug?port=5858 to start debugging
Ah, I see what I did wrong. For some reason I did node --debug-brk
with out adding the path
Its working now, thanks so much. I apologize for dragging this on for
so long. But hopefully this will be useful for other windows users in
This can be accomplished by starting up
node-inspector and starting
grunt in debug mode. Once that's done, you can step through your
Gruntfile.js within Chrome as you normally would.
If you don't already have
node-inspector, install it using
npm install -g node-inspector. Then start it up in one terminal/command prompt:
$ node-inspector Node Inspector v0.7.3 Visit http://127.0.0.1:8080/debug?port=5858 to start debugging.
Next, locate your
grunt command from the command line. If you installed grunt globally (using
npm install -g grunt-cli) then it will most likely be in
/usr/local/bin for *nix or Mac machines. For Windows machines, the
grunt.cmd file points to where the
grunt script is located. Most likely the
grunt script is located in
Once you've found the location of the script, use
node --debug-brk to execute this script, thus starting grunt in debug mode breaking on the first line of code in the file. So for instance, imagine the grunt script is located at
$ node --debug-brk /usr/bin/grunt debugger listening on port 5858
You'll know you're successful when you see
debugger listening on port 5858 as the output, which means that the grunt script has halted execution and is waiting to be stepped through with the debugger.
Now bring up Chrome and point it to
http://127.0.0.1:8080/debug?port=5858. Within Chrome, open and add break points in your
Gruntfile.js, and step through as you normally would.