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:

error message using node-inspector

enter image description here

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.

  1. found grunt.cmd file on windows machine located in c:\users\khollenbeck\appdata\roaming\npm. opened grunt.cmd file , found following....

    enter image description here

  2. this lead me c:\users\khollenbeck\appdata\roaming\npm\node_modules\grunt-cli\bin contained file called grunt. , there @ top of file. changed code #!/usr/bin/env node #!/usr/bin/env node --debug-brk

  3. 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

  4. 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

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -