Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debugging learnyounode debugs the learnyounode.js and not the child script #15

Open
dave00galloway opened this issue Feb 6, 2015 · 0 comments

Comments

@dave00galloway
Copy link

when trying to debug a simple sample script in learnyounode, the learnyounode.js can be stepped through, but the sample script cannot be. according to the discussion below, this is a bug in learnyounode.

steps to reproduce

  1. install learnyounode
  2. install nodeclipse for mac (see
    https://github.com/joyent/node/wiki/using-eclipse-as-node-applications-debugger and http://www.nodeclipse.org/usage and http://sourceforge.net/projects/nodeclipse/files/Enide-Studio-2014/0.11-preview/Enide-Studio-2014-011-20140228-macosx-cocoa-x86_64.zip/download)
  3. create sample script:-
    var a = '2';
    var b = '3';
    debugger;
    console.log(a + b);
  4. save as debugme.js
  5. launch debug from terminal
    node --debug-brk /usr/local/lib/node_modules/learnyounode/learnyounode.js run debugme.js
  6. hit debug button in eclipse
    expected :- breakpoint is hit on the debugger; statement
  7. actual :- can step through code in learnyounode.js, but then the debug session terminates before going in to the debugme.js but the output is printed to the terminal (not the console)

please fix as this will help with trickier scripts to figure out what is going on when they are running!

ref:- https://gitter.im/nodeschool/discussions

does anyone know how to debug learnyounode modules with nodeclipse?

@dave00galloway

if I start debugging using node --debug-brk program.js then I can step through the code, but because the script wasn't launched by learnyounode, the arguments aren't passed to the process.argv[] array
i followed https://github.com/joyent/node/wiki/using-eclipse-as-node-applications-debugger and http://www.nodeclipse.org/usage and http://sourceforge.net/projects/nodeclipse/files/Enide-Studio-2014/0.11-preview/Enide-Studio-2014-011-20140228-macosx-cocoa-x86_64.zip/download to get this far

@martinheidegger

learnyounode is only just a nodejs script 😄
This message was deleted
dave00galloway 35 minutes ago
thanks for the reply .. so... how do i debug it? how do I pass the script that I want to debug (program.js) to learnyounode with the debug-brk argument?

@martinheidegger

(bash syntax)
npm root -g … will give you the path where global modules are stored
$(npm root -g)/learnyounode …… is the folder for the learnyounode code
node --debug /usr/local/lib/node_modules/learnyounode/learnyounode.js …. runs learnyounode in debug mode
node --debug /usr/local/lib/node_modules/learnyounode/learnyounode.js run 01.js … runs the 01.js script in debug mode

@dave00galloway

thanks again - getting closer but not quite there. the steps you describe take me into the learnyounode.js file and allow me to step through it. pretty cool, but at no point do I hit the breakpoint in program.js that I set just after variable declarations.

@martinheidegger

add a “debugger” statement?

@dave00galloway

the script program.js IS called, because after the debugger exits, the output from program.js is output to the terminal

@martinheidegger

how did you add the breakpoint?

@dave00galloway

double clicked in margin in eclipse, sorry, nodeclipse

@martinheidegger

just write in your code: debugger;
like
var a = “2”;
var b = “3”;
debugger;
console.log(a + b);

@dave00galloway

same thing happens, step through the learnyounode.js file, but doesn't hit the breakpoint at the debugger; statement

@martinheidegger

😔
.oO( ….? …. )

@dave00galloway

here's the output

davids-MacBook-Pro:LearnYouNode dave$ node --debug-brk /usr/local/lib/node_modules/learnyounode/learnyounode.js run debugme.js
debugger listening on port 5858
23
davids-MacBook-Pro:LearnYouNode dave$ node /usr/local/lib/node_modules/learnyounode/learnyounode.js run debugme.js
23

so, the simple script you provided does get called, but I can only step through the learnyounode code, not the debugme.js code
any suggestions?

@martinheidegger

http://stackoverflow.com/questions/9507345/use-node-js-command-line-debugger-on-child-process#answer-18614851
Seems like learnyounode forgot to ensure this happens https://github.com/rvagg/workshopper-exercise/blob/master/execute.js#L80
i smell BUG or rather: ENHANCEMENT ...
Seems like someone has to write a pull-request ...
.oO( or at least an issue )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant