You can spawn a child_process with replacing bash in Node by invoking the sh command using the -c flag.
The sh command uses your default bash interpreter, and the -c flag prompts the interpreter to read commands from a string, that is: $(echo $PATH) . Then additional flags are passed to their usual positional links, such as: $0 , $1 , ect.
So an example could be:
const spawn = require('child_process').spawn; const prg = 'sh', args = [ '-c', 'echo $($0 $1)', 'ls', // $0 '-la' // $1 ], opts = { stdio: 'inherit' }; // Print a directory listing, Eg: 'ls -la' const child = spawn(prg, args, opts);
source share