错误:使用非root用户使用Node.js child_process时,在errnoException(child_process.j2:980:11)处产生ENOENT

我遇到了这个错误在MacOS和Linux中使用node.js v0.10.12,这段代码在Windows 7中工作正常。唯一的区别是在Windows 7我有pipe理员身份,在MacOSX和Linux上,我不是根,只是计划用户。

我们是否需要root来与child_process一起工作? 任何线索,为什么它在一些操作系统,而不是所有的? 非常感谢,

这是代码:

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); } 

大家好:我想我得到了我的答案。 之所以没有在其他操作系统上工作的原因是我的configuration。

如果没有在系统path上configuration节点,那么除非指定了path,否则无处不在。