javascript - node.js 错误 : ENOSYS spawn when executing command line command

标签 javascript unix node.js

我试图在 unix 下运行 node.js,并得到这个错误:

var exec = require('child_process').exec;

var commandLine = "/var/util/generate 300 300 > /tmp/barcode.png";
var childProcess;

http.createServer(function (req, res) {

var request = url.parse(req.url, true);
var action = request.pathname;

if (action == '/barcode.png') {

    console.log('executes commandLine');

    // executes 'commandLine'
    childProcess = exec(commandLine, 
        function (error, stdout, stderr) {
            sys.print('stdout: ' + stdout);
            sys.print('stderr: ' + stderr);
            var img = fs.readFileSync('/tmp/barcode.png');
            res.writeHead(200, {
                'Content-Type' : 'image/png'
            });
            res.end(img, 'binary');
            if (error !== null) {
                console.log('exec error: ' + error);
            }
        });
} else {
    res.writeHead(200, {
        'Content-Type' : 'text/plain'
    });
    res.end('QR Generate service reply: Please provide correct request parameter \n');
    }       
}).listen(8888);

console.log("QR Generate service running at http://localhost:8888 ");

但是我得到:

Error: ENOSYS spawn
    at errnoException (child_process.js:476:11)
    at ChildProcess.spawn (child_process.js:443:11)
    at child_process.js:341:9
    at Object.execFile (child_process.js:250:15)
    at child_process.js:217:18
    at Server.<anonymous> (/base/usr/node/service.js:139:18)
    at Server.emit (events.js:70:17)
    at HTTPParser.onIncoming (http.js:1479:12)
    at HTTPParser.onHeadersComplete (http.js:102:31)
    at Socket.ondata (http.js:1375:22)

当它命中 exec(

怎么了?

Node 版本为0.6.4

最佳答案

我的问题没有解决方案,它是在不支持在服务期间生成的平台上执行的。

关于javascript - node.js 错误 : ENOSYS spawn when executing command line command,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8477908/

相关文章:

c++ - 进程 fork 后 RAII 对象会发生什么?

javascript - 通过在 Protractor 测试中发布一些 JSON 数据来调用删除其余 API

javascript - 如何使用 ExpressJS 访问多个数据库?

javascript - NodeJS - setTimeout 完成后运行函数

javascript - 如何将远程 javascript 加载到 SpiderMonkey 上下文中?

javascript - 调用 jQuery html 方法时出错

c - (struct _IO_FILE *)->_IO_read_base 如何设置?

javascript - Travis CI 与 Amazon Elastic Beanstalk

javascript - 在 javascript 或 jquery 中按名称获取单选框选中的值

python - 如何检查上传到服务器的文件的 mimetype?