【问题标题】:Is there a Node.js equivalent to Python's subprocess.run?是否有等效于 Python 的 subprocess.run 的 Node.js?
【发布时间】:2020-10-22 06:22:29
【问题描述】:

我希望从 node.js 执行 shell 命令。我希望将标准输出显示到终端。在 python 中,我可以使用 subprocess.run 来做到这一点。在 node.js 中,我看到 child_process.exec,但这会返回 stdout 的缓冲区,而不是自动显示到终端。

【问题讨论】:

    标签: python node.js terminal subprocess child-process


    【解决方案1】:

    就我而言,我使用child_process.execAsyncstdio 选项设置为inherit 使其工作,如下所示:

    child_process.execAsync("git push --tags", { stdio: "inherit" })

    我需要 git 来显示密码提示并允许用户进行输入。

    【讨论】:

      猜你喜欢
      • 2017-05-24
      • 1970-01-01
      • 1970-01-01
      • 2010-11-28
      • 2019-09-12
      • 2016-04-21
      • 1970-01-01
      • 2011-05-31
      • 2021-11-04
      相关资源
      最近更新 更多