What exactly is the difference between the util.error([...])
and console.error([...])
?
In both of the methods it prints to stderr.
Same as util.debug() except this will output all arguments immediately to stderr.
A synchronous output function. Will block the process and output string immediately to stderr.
Same as console.log but prints to stderr.
Prints to stdout with newline. This function can take multiple arguments in a printf()-like way. Example:
console.log('count: %d', count);
If formatting elements are not found in the first string then util.inspect is used on each argument. See util.format() for more information.
According to is node.js' console.log asynchronous? the console.log is asynchronous(node>=0.6), therefore also console.error. But util.error will block the process and output to stderr, according to the documentation above.