Saving the output of a child process in a variable in the parent in NodeJS
问题 I would like to start a child process in NodeJS and save it's output into a variable. The following code gives it to stdout: require("child_process").execSync("echo Hello World", {"stdio": "inherit"}); I have something in mind that is similar to this code: var test; require("child_process").execSync("echo Hello World", {"stdio": "test"}); console.log(test); The value of test was supposed to be Hello World . Which does not work, since "test" is not a valid stdio value. Perhaps this is possible