I ran into this error using node.js v0.10.12 in MacOS and linux, this piece of code work fine in windows 7. The only differences is on windows 7 I have admin id, on MacOSX and linux , I am not root and just plan user.
Do we need to be root to work with child_process? Any clue about why it fails on some OS and not all? Thanks so much,
This is the code:
var spawn = require('child_process').spawn; try { var child = spawn('node', ['plusone.js']); //call every minute setInterval(function() { // var number = Math.floor(Math.random() * 10000); child.stdin.write(number +'\n'); child.stdout.once('data', function(data) { console.log('child replied to '+ number +' with ' +data); }); },1500); child.stderr.on('data', function(data) { process.stdout.write(data); }); } catch (e) { console.log("entering catch block"); console.log(e); }
nodefound in the PATH for that user.