javascriptnode.jsjavascript-debuggernode-repl

is it possible to debug node repl


Is is it possible debug NODE REPL. node cmd bring the repl prompt >. within the prompt is it possible to start the debugger. say for eg

> hello = function(){
....debugger;
....console.log('hello');
}
>hello() --> should run in the debugger..

Solution

  • Yes

    New way: node 8 >=

    node --debug is marked for deprecation.

    [DEP0062] DeprecationWarning: node --debug and node --debug-brk are invalid. Please use node --inspect or node --inspect-brk instead.

    node --inspect is the way moving forward.

    Old way

    Start the repl with node --debug. Then you can can use node-inspector (an npm package) from a separate terminal, and debug in your browser with the chrome developer tools by opening http://localhost:8080/debug?port=5858 in chrome. You can, for example, set a breakpoint in the repl.js file in the complete function, and if you go to the node repl and hit TAB, it will trigger the breakpoint and you can debug it.

    If you want the coffee-script repl, it's coffee --nodejs --debug.