Is there a better way to log and debug objects in Node?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aryankanse6
    New Member
    • Jun 2020
    • 3

    Is there a better way to log and debug objects in Node?

    I am developing a server-side app that cannot run in the browser, and therefore I cannot debug with DevTools.

    If I want to debug an object I need to print the object to shell using

    JSON.stringify OR require('util') .inspect
    These work okay but it's not anywhere near as good as a browser's DevTools.

    So, I am wondering, is there a better way to debug objects? Is there some sort of DevTools like shell for Node. I am guessing the answer is "no", but I am asking anyway.
    Last edited by Niheel; Feb 14 '21, 03:31 PM.
  • dreamtext
    Recognized Expert New Member
    • Feb 2021
    • 24

    #2
    You have to enable inspector when you run your node server locally by using the --inspect switch.

    This will open up a port where node will communicate with an inspector client usually on port : 9229

    Use this as a resource:
    Node.js® is a free, open-source, cross-platform JavaScript runtime environment that lets developers create servers, web apps, command line tools and scripts.

    Comment

    Working...