3

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.)

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.