Process

process.stderr.write()

Writes diagnostics to the standard error stream, separate from ordinary machine-readable output. The return boolean describes buffering rather than successful receipt. A subprocess captures the two streams separately here. Tested on Node.js 22.16.0. Example output (one line per entry): ["0 result note"].

Formal Syntax & Structure

nodejs syntaxnodejs
process.stderr.write(chunk[, encoding][, callback])

Parameters & Attributes

NameTypeDescription
chunkstring | BufferData to write.
encodingstringString encoding.
callbackFunctionWrite completion callback.

Return Value

boolean

Whether more data can be accepted without waiting for drain.

Working Example

Example Snippetnodejs
import { spawnSync } from 'node:child_process';const r = spawnSync(process.execPath, ['-e', "process.stdout.write('result');process.stderr.write('note')"], { encoding: 'utf8', timeout: 3000 });console.log(r.status, r.stdout, r.stderr);
Node.js Reference