0

I would like to execute a command from inside a typescript file.

  • The typescript file doesn't have to continue, ideally it would end.
  • The command and all its output would be output to screen, as if it was run from command prompt.

I have tried this without success

var exec = require('child_process').exec
exec('npm run start', (err, stdout, stderr) =>console.log(stdout));
Dan Pettis
  • 113
  • 5

1 Answers1

1

What you are looking for is spawn:

const { spawn } = require('child_process')

spawn('npm run start', [], { shell: true, stdio: 'inherit' })
aleksxor
  • 7,535
  • 1
  • 22
  • 27