How can I get the full object in Node.js's console.log(), rather than '[Object]'?

前端 未结 17 2905
一向
一向 2020-11-22 02:59

When debugging using console.log(), how can I get the full object?

const myObject = {
   \"a\":\"a\",
   \"b\":{
      \"c\":\"c\",
      \"d\":         


        
17条回答
  •  名媛妹妹
    2020-11-22 03:06

    A good way to inspect objects is to use node --inspect option with Chrome DevTools for Node.

    node.exe --inspect www.js
    

    Open chrome://inspect/#devices in chrome and click Open dedicated DevTools for Node

    Now every logged object is available in inspector like regular JS running in chrome.

    There is no need to reopen inspector, it connects to node automatically as soon as node starts or restarts. Both --inspect and Chrome DevTools for Node may not be available in older versions of Node and Chrome.

提交回复
热议问题