Is there a Node.js equivalent to Python's subprocess.run?

Viewed 698

I am looking to execute shell command from node.js. I would like the stdout to be displayed to the terminal. In python I can do this with subprocess.run. In node.js I see child_process.exec, but this returns a buffer of stdout instead of automatically displaying to the terminal.

1 Answers

In my case I got it working using child_process.execAsync with the stdio option set to inherit like this:

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

I needed git to show the prompt for the passphrase and allow user to make the input.

Related