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?
Asked
Active
Viewed 589 times
1
-
Use `console.error()` – Shubham Dixit Sep 07 '20 at 15:49
-
@Shubh, it doesn't table. – Qwertiy Nov 11 '20 at 21:28
1 Answers
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
-
Works great, especially since I can have 2 console instances in the same prorgam. – ma1234 Sep 08 '20 at 22:08