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
| Name | Type | Description |
|---|---|---|
| file | string | Executable. |
| args | string[] | Arguments. |
| options | object | Process 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());