Unsupported option passed to child_process function
Production Risk
Low — caught at startup; choose the right child_process function for your use case.
Thrown when an option that is not supported by the specific child_process function is passed to it. Different functions (spawn, fork, exec, execFile) support different option sets; some options are mutually exclusive or only valid for specific functions.
- 1Passing a shell option to fork() which does not support it
- 2Combining mutually exclusive options in a child_process call
- 3Typo in an option name causing it to be unrecognised
Triggered when the child_process module validates options and finds an incompatible or unknown option.
const { fork } = require('child_process');
fork('./worker.js', { shell: true }); // shell not supported by fork()expected output
Error [ERR_CHILD_PROCESS_UNSUPPORTED_OPTION]: options.shell is not supported for fork()
Fix 1
Use the correct function for your options
WHEN When you need shell features
const { exec } = require('child_process');
// exec() supports shell execution
exec('ls -la', (err, stdout) => { console.log(stdout); });Why this works
exec() and spawn() with shell:true support shell features; fork() is for Node.js module IPC.
Fix 2
Check the Node.js docs for supported options per function
WHEN Before using a new option
// fork() supported options: cwd, env, execPath, execArgv, silent, stdio, uid, gid, serialization, signal, killSignal, timeout
const child = fork('./worker.js', { silent: true, uid: 1000 });Why this works
Using only documented options for each function avoids validation errors.
const { fork } = require('child_process');
fork('./worker.js', { shell: true }); // shell not supported by fork() // this triggers ERR_CHILD_PROCESS_UNSUPPORTED_OPTIONtry {
// operation that may throw ERR_CHILD_PROCESS_UNSUPPORTED_OPTION
riskyOperation()
} catch (err) {
if (err.code === 'ERR_CHILD_PROCESS_UNSUPPORTED_OPTION') {
console.error('ERR_CHILD_PROCESS_UNSUPPORTED_OPTION:', err.message)
} else {
throw err
}
}// Validate inputs before calling the operation
function safe_err_child_process_unsupported_option(...args) {
// validate args here
return performOperation(...args)
}✕ Pass shell or argv0 to fork()
fork() has a restricted option set; unsupported options throw immediately.
Node.js Error Codes Documentation
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev