#2287·yargs

argv._ contains file path when process is a forked child of an electron process

Author: marie-bnlCreated Jan 7, 2023Updated Sep 12, 2026
Labelsquestion

Issue

When yargs is used to parse arguments from a child process that was started by forking an electron process, argv._ contains the child process path, which is unexpected.

Note: the issue also occurs on yargs@next

Reproduce

Here is a minimal reproducible example

To run this example, just install dependencies with npm install and run :

npm run child: runs the child itself

javascript
[]

The list is empty, which is the expected behaviour

npm run parent: runs a non-electron classic nodejs parent which forks the child

javascript
[]

The list is still empty, which shows the problem doesn't occur when just using NodeJS, and is related to Electron (I didn't test with other interpreters though)

npm run main: starts the electron application

javascript
[ '/home/victor/yargs-issue/child.js' ]

The list contains the child process path, which is the unexpected behaviour