Run block of bash / shell in node's spawn Run block of bash / shell in node's spawn shell shell

Run block of bash / shell in node's spawn


spawn() does not involve a shell, so in order to have it execute shell commands, you must invoke the shell executable explicitly and pass the shell command(s) as an argument:

const child = spawn('/bin/sh', [ '-c',  `echo "alpha"echo "beta"` ])

Note I've used /bin/sh rather than /bin/bash in an effort to make your command run on a wider array of [Unix-like] platforms.
All major POSIX-like shells accept a command string via the -c option.