1

I find that console.table() is good, in a few cases, for error messages. However, it doesn't print to stderr. How do I print console.table to stderr in Node.js?

Qwertiy
  • 19,681
  • 15
  • 61
  • 128
ma1234
  • 445
  • 1
  • 4
  • 9

1 Answers1

5

In Node.js, one can instantiate a custom Console instance with a different writable stream than stdout using the console module, e.g.:

const { Console } = require("console");
const console = new Console(process.stderr);

This would have any method that typically uses stdout, including table(), use stderr instead.

Dave Shifflett
  • 416
  • 3
  • 5