Run shell command from JavaScript in node-webkit?

Is there a way to run a shell command from JavaScript in node-webkit? There are many questions, but this did not help me.

I am trying to create a simple desktop application to list installed tools. I created the node module 'tools-v', which is installed globally and works when I run it on the command line. This module runs several commands: npm -v, node -v, git -vetc. I am on Windows 7.

//var sys = require('sys');
var exec = require('child_process').exec;
//var toolsv = (process.platform === "win32" ? "tools-v.cmd" : "tools-v");
$(document).ready(function() {
    //myCmd = "C:\\Users\\win7\\AppData\\Roaming\\npm\\tools-v.cmd";
    //myCmd = toolsv;
    myCmd = 'tools-v';
    //gui.Shell.openItem('firefox',function(error, stdout, stderr) { });
    //opening Firefox works.
    exec(myCmd,  function (error, stdout, stderr) {
        //detached: true;
        console.log('stdout: ' + stdout);
        $('#output').append('stdout: ' + stdout)
        if (error !== null) {
          console.log('exec error: ' + error);
        }
    });
});

I always get the error: ""exec error: Error: spawn ENOENT""

I tried spawn instead of exec. I also tried several other commands besides the node module. Thank.

+4
source share
1

, . , node -webkit. grunt spawn.

+1

All Articles