Most Popular Tutorials
Most Popular Tutorials :-

Simply Easy Learning at Your Fingertips. Click Tutorials Menu to view More Tutorial List





How to debugg node.js programs?

You can debug Node.js application by using

  • Core Node.js debugger
  • Node Inspector
  • Built-in debugger in IDEs
  • Core Node.js Debugger

    Node.js provides built-in non-graphic debugging tool that can be used on all platforms. It provides different commands for debugging Node.js application.

    File Name :

    var fs = require('fs');
    fs.readFile('test.txt', 'utf8', function (err, data) {
    debugger;
    if (err) throw err;
    console.log(data);
    });

    Write debugger in your JavaScript code where you want debugger to stop.

    Now, to debug the above application, run the following command.

    File Name :

    node debug app.js

    The above command starts the debugger and stops at the first line as shown below.

    As you can see in the above figure, > symbol indicates the current debugging statement. Use next to move on the next statement.

    In the above figure, next command will set the debugger on the next line. The > is now pointing to next statement. Use cont to stop the execution at next "debugger", if any.

    you can see that cont command stops at the "debugger".

    File Name :

    Command Description
    next :- Stop at the next statement.
    cont :- Continue execute and stop at the debugger statement if any.
    step :- Step in function.
    out :- Step out of function.
    watch :- Add the expression or variable into watch.
    watcher :- See the value of all expressions and variables added into watch.
    Pause :- Pause running code.





    Previous Next


    Trending Tutorials




    Review & Rating

    0.0 / 5

    0 Review

    5
    (0)

    4
    (0)

    3
    (0)

    2
    (0)

    1
    (0)

    Write Review Here