Building my project using Angular-Cli works when I use it directly from my terminal window like this:
$ ng build
Now I'd like to run it from nodejs
using spawn. However,
const spawn = require('child_process').spawn;
const bld = spawn("ng build");
throws:
child process has an error with code Error: spawn ng build ENOENT
child process exited with code -2
Why is this happening? (I am running everything from inside the same folder.)
Spawn doesn't behave like a command line.
You send the command and args separately like:
spawn('ng', ['build'])
In your case it tried to do ng\ build
and can not find that file.