在node-webkit中使用JavaScript运行shell命令?

有什么方法可以从node-webkit的JavaScript运行shell命令? 有很多类似的问题,但它并没有帮助我。

我正在尝试构build简单的桌面应用程序来列出已安装的工具。 我已经创build了节点模块“tools-v”,它是全局安装的,并且可以在命令行中运行。 这个模块运行几个命令: npm -vnode -vgit -v等。我在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); } }); }); 

我总是得到错误: ""exec error: Error: spawn ENOENT""

我试过产生而不是执行。 我也尝试了几个其他的命令,旁边的节点模块。 谢谢。

其实,这个代码的作品。 我只是没有构build完整的应用程序,我testing了它通过崇高的构buildnode-webkit。 预先形成完整的构build与咕噜声解决了每一个spawn问题。