javascript - How to debug a Gruntfile with breakpoints using node-inspector, Windows 7? -
so have spent past couple days trying work no luck. of solutions have found seem work "okay" debugging node applications. haven't had luck debugging grunt stand alone. able set breakpoints in gruntfile , either step through code either browser or ide.
i have tried following:
- debugging using intellij ide using grunt console (process finished exit code 6)
- debugging nodeeclipse (this sort of works okay doesn't hit breakpoints set in eclipse, not intuitive)
- debugging using node-inspector (this 1 sort of works. can step through little ways using f11 , f10 in chrome. crashes. using f8 skip break point never works.)
error message using node-inspector
so node-inspector feels has gotten me closest want. here did following:
from grunt directory ran following commands:
grunt node-inspector node --debug-brk gruntfile.js
and there went localhost:8080/debug?port=5858
debug gruntfile.js. mentioned above, hit f8 skip breakpoint crashes above error. has had success using method try debug gruntfile? far search efforts have not found documented way of doing this. useful or beneficial information future users. using windows 7 way. in advance.
update:
i have tried following suggested @dylants no luck far.
found grunt.cmd file on windows machine located in
c:\users\khollenbeck\appdata\roaming\npm
. openedgrunt.cmd
file , found following....this lead me
c:\users\khollenbeck\appdata\roaming\npm\node_modules\grunt-cli\bin
contained file calledgrunt
. , there @ top of file. changed code#!/usr/bin/env node
#!/usr/bin/env node --debug-brk
after doing command
node-inspector c:\path\to\gruntfile grunt
got following.node inspector v0.7.3 visit http://localhost:8080/debug?port=5858 start debugging
next ran
grunt
command grunt dir. (leaving server running in original command prompt)
from here expected gruntfile.js show in source of chrome dev tools. expected able set breakpoints there. did not happen. instead ran way through gruntfile without breaking or loading in browser.
edit:
ah, see did wrong. reason did node --debug-brk out adding path c:\users\khollenbeck\appdata\roaming\npm\node_modules\grunt-cli\bin\grunt. working now, much. apologize dragging on long. useful other windows users in future.
this can accomplished starting node-inspector
, starting grunt
in debug mode. once that's done, can step through gruntfile.js
within chrome would.
start node-inspector
if don't have node-inspector
, install using npm install -g node-inspector
. start in 1 terminal/command prompt:
$ node-inspector node inspector v0.7.3 visit http://127.0.0.1:8080/debug?port=5858 start debugging.
run grunt in debug mode
next, locate grunt
script. javascript file executed when run grunt
command command line. if installed grunt globally (using npm install -g grunt-cli
) in /usr/bin
or /usr/local/bin
*nix or mac machines. windows machines, grunt.cmd
file points grunt
script located. grunt
script located in c:\users\<username>\appdata\roaming\npm\node_modules\grunt-cli\bin
.
once you've found location of script, use node --debug-brk
execute script, starting grunt in debug mode breaking on first line of code in file. instance, imagine grunt script located @ /usr/bin/grunt
:
$ node --debug-brk /usr/bin/grunt debugger listening on port 5858
you'll know you're successful when see debugger listening on port 5858
output, means grunt script has halted execution , waiting stepped through debugger.
debug chrome
now bring chrome , point http://127.0.0.1:8080/debug?port=5858
. within chrome, open , add break points in gruntfile.js
, , step through would.
Comments
Post a Comment