diff --git a/lib/internal/console/constructor.js b/lib/internal/console/constructor.js index 1b9c4e7ba03c11..b8f2ae29244f9c 100644 --- a/lib/internal/console/constructor.js +++ b/lib/internal/console/constructor.js @@ -346,7 +346,7 @@ const consoleMethods = { clear() { // It only makes sense to clear if _stdout is a TTY. // Otherwise, do nothing. - if (this._stdout.isTTY) { + if (this._stdout.isTTY && process.env.TERM !== 'dumb') { // The require is here intentionally to avoid readline being // required too early when console is first loaded. const { cursorTo, clearScreenDown } = require('readline'); diff --git a/test/pseudo-tty/console-dumb-tty.js b/test/pseudo-tty/console-dumb-tty.js new file mode 100644 index 00000000000000..93f9b99b0ff0fb --- /dev/null +++ b/test/pseudo-tty/console-dumb-tty.js @@ -0,0 +1,9 @@ +'use strict'; +require('../common'); + +process.env.TERM = 'dumb'; + +console.log({ foo: 'bar' }); +console.dir({ foo: 'bar' }); +console.log('%s q', 'string'); +console.log('%o with object format param', { foo: 'bar' }); diff --git a/test/pseudo-tty/console-dumb-tty.out b/test/pseudo-tty/console-dumb-tty.out new file mode 100644 index 00000000000000..c776b496474307 --- /dev/null +++ b/test/pseudo-tty/console-dumb-tty.out @@ -0,0 +1,4 @@ +{ foo: 'bar' } +{ foo: 'bar' } +string q +{ foo: 'bar' } with object format param