title: How to debug a Gruntfile with breakpoints using node-inspector, Windows 7?
body: <p>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.</p>
  
  <p><strong>I have tried the following:</strong></p>
  
  <ul>
  <li><a href="http://www.jetbrains.com/webstorm/webhelp/using-grunt-task-runner.html" rel="noreferrer">Debugging using intelliJ IDE Using Grunt Console</a> (<em>Process finished with exit code 6</em>)</li>
  <li><a href="https://github.com/joyent/node/wiki/using-eclipse-as-node-applications-debugger" rel="noreferrer">Debugging with Nodeeclipse</a> (<em>This sort of works okay but doesn't hit the breakpoints set in eclipse, not very intuitive</em>)</li>
  <li><a href="https://github.com/node-inspector/node-inspector" rel="noreferrer">Debugging using node-inspector</a> (<em>This one also sort of works. I can step through a little ways using F11 and F10 in chrome. But eventually it just crashes. Using F8 to skip to break point never works.</em>)</li>
  </ul>
  
  <p><strong>ERROR MESSAGE USING NODE-INSPECTOR</strong></p>
  
  <p><img src="https://i.stack.imgur.com/klz3P.png" alt="enter image description here"></p>
  
  <p>So currently node-inspector feels like it has gotten me the closest to what I want. To get here I did the following:</p>
  
  <p>From my grunt directory I ran the following commands:</p>
  
  <pre><code>grunt node-inspector
  node --debug-brk Gruntfile.js
  </code></pre>
  
  <p>And then from there I went to <code>localhost:8080/debug?port=5858</code> to debug my Gruntfile.js. But like I mentioned above, as soon as I hit F8 to skip to breakpoint it crashes with the above error. Has anybody had any success using this method to try to debug a Gruntfile? So far from my search efforts I have not found a very well documented way of doing this. So hopefully this will be useful or beneficial information for future users. Also I am using <strong>Windows 7</strong> by the way. Thanks in advance.</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I have tried the following suggested by @dylants with no luck so far.</p>
  
  <ol>
  <li><p>Found the grunt.cmd file on windows machine located in <code>C:\Users\khollenbeck\AppData\Roaming\npm</code>. Opened up <code>grunt.cmd</code> file and found the following....</p>
  
  <p><img src="https://i.stack.imgur.com/C2F48.png" alt="enter image description here"></p></li>
  <li><p>This lead me to <code>C:\Users\khollenbeck\AppData\Roaming\npm\node_modules\grunt-cli\bin</code> which contained a file called <code>grunt</code>. And from there at the top of the file. I changed this code <code>#!/usr/bin/env node</code> to <code>#!/usr/bin/env node --debug-brk</code></p></li>
  <li><p>After doing this command <code>node-inspector C:\path\to\gruntfile grunt</code> I got the following.</p>
  
  <p><code>Node Inspector v0.7.3
   Visit http://localhost:8080/debug?port=5858 to start debugging</code></p></li>
  <li><p>Next I ran the <code>grunt</code> command from grunt dir. (<em>leaving the server running in original command prompt</em>) </p></li>
  </ol>
  
  <p>From here I expected Gruntfile.js to show up in the source of chrome dev tools. I also expected to be able to set breakpoints from there. This did not happen. Instead it just ran all the way through the Gruntfile without breaking or loading in the browser.</p>
  
  <p><strong>Edit:</strong></p>
  
  <blockquote>
    <p>Ah, I see what I did wrong. For some reason I did node --debug-brk
    with out adding the path
    C:\Users\khollenbeck\AppData\Roaming\npm\node_modules\grunt-cli\bin\grunt.
    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
    the future.</p>
  </blockquote>