1
我有一个程序,我使用child_process以编程方式在Node.js上运行。如何让用户在Node.js中输入数据到产生的进程
var spawnedProcess = childProcess.spawn(command, args);
spawnedProcess.stdout.setEncoding("utf8");
spawnedProcess.stdout.on("data", function(data) {
return process.stdout.write(data);
});
process.stdin.pipe(spawnedProcess.stdin);
我认为这将工作,因为我输入到shell中的所有内容都将被传送到派生进程的标准输入中。
我可以看到我输入的内容,当我按Enter键时,只需给我一个新的行。外壳没有响应任何输入。
任何线索?
你试图运行的命令是什么? – thejh
“npm init”和“jitsu deploy”。 – ajsie
npm可以通过编程方式使用(可以将其作为模块安装),但不确定关于jitsu。 – thejh