'How to get expandable objects view as output in VS Code node terminal?

I would like to have collapsible/ expandable objects in the terminal output in VS Code like on the browser console.

Here is an example:

Picture of expandable object in browser console

In the debug terminal it works only if I toggle a breakpoint before the end of the program, but otherwise I get the error "No debugger available, can not send 'variables'".

So I'm thinking if the functionality is there, there must be a way to get it even without setting breakpoints every time. Right?



Solution 1:[1]

use

"outputCapture": "std"

in launch.json

Solution 2:[2]

Use console.dir() instead of console.log().

Use this following example, to display all nested objects:

console.dir(yourStuff, { depth: null })

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Iceto04
Solution 2 scottrod