Child process

child_process.execFileSync()

Returns buffered output for a successful direct executable invocation. Nonzero exit throws. Keep offline uses small and bounded. Tested on Node.js 22.16.0. Example output (one line per entry): ["7"].

Formal Syntax & Structure

nodejs syntaxnodejs
execFileSync(file[, args][, options])

Parameters & Attributes

NameTypeDescription
filestringExecutable.
argsstring[]Arguments.
optionsobjectProcess settings.

Return Value

Buffer | string

Captured stdout.

Working Example

Example Snippetnodejs
import { execFileSync } from 'node:child_process';console.log(execFileSync(process.execPath, ['-e', 'console.log(7)'], { encoding: 'utf8', timeout: 1000, maxBuffer: 1024, env: {} }).trim());
Node.js Reference