This is the code to execute
cp.exec(\"cc -Wall /tmp/test.c -o /tmp/test\", function(e, stdout, stderr) {
if (e) {
var errorstr = \"Comp
I'm a bit worried about the output in the console.
{ [Error: Command failed: ] killed: false, code: false, signal: undefined }
doesn't look like a proper JSON/JavaScript object, especially the [Error: Command failed: ]
part; there is at least a comma missing.
Suggestions:
Run the command from the command line and check the exit code (use echo $?
). If the exit code is != 0, then this means the command "failed" (whatever that might mean).
When the command fails, nodejs says it will put the exit code into e.code
(which I'm missing in your output...). Find out what happened to this value.
Try if(e !== null)
instead of if(e)
. Shouldn't make a difference, though.
Instead of calling the compiler directly, call a shell script which redirects stderr/stdout to a file (or save a copy using cc ... |& tee /tmp/cc.log
) to make sure no part of the complex setup swallows important information.