Node.js: printing to console without a trailing newline?

Evan Carroll picture Evan Carroll · May 27, 2011 · Viewed 372.3k times · Source

Is there a method for printing to the console without a trailing newline? The console object documentation doesn't say anything regarding that:

console.log()

Prints to stdout with newline. This function can take multiple arguments in a printf()-like way. Example:

console.log('count: %d', count);

If formating elements are not found in the first string then util.inspect is used on each argument.

Answer

onteria_ picture onteria_ · May 27, 2011

You can use process.stdout.write():

process.stdout.write("hello: ");

See the docs for details.