【发布时间】:2018-10-09 20:58:26
【问题描述】:
这将引发 ENOENT 错误:
const cmd = 'bash my/path/to/script.sh';
const process = spawn(cmd);
process.on('exit', (code) => {
console.log("Child exited");
});
虽然这不会按预期执行脚本:
const cmd = 'bash my/path/to/script.sh';
exec(cmd, function(err, stdout, stderr) {
console.log(stdout);
});
现在,我想要来自spawn() 的数据流并让它工作。这种行为可能来自哪里的任何建议?
我检查了pwd,两者的当前工作目录相同。
【问题讨论】:
标签: javascript node.js exec child-process spawn