【发布时间】:2014-07-08 23:43:16
【问题描述】:
我想用 nodejs 打开谷歌浏览器,但是我得到了这个错误(我使用了 execFile 和 spawn),
代码
var execFile = require('child_process').execFile,
spawn = require('child_process').spawn,
spawn('C\\Program Files\\Google\\Chrome\\Application\\chrome.exe', function (error, stdout, stderr) {
if (error !== null) { console.log('exec error: ' + error); }
});
events.js:72
throw er; // Unhandled 'error' event
^
Error: spawn ENOENT
at errnoException (child_process.js:998:11)
at Process.ChildProcess._handle.onexit (child_process.js:789:34)
【问题讨论】:
-
我认为,您在文件路径中缺少
:。我觉得应该是C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe -
我用 start iexplore 修复了它
-
但是现在我在启动 linux 命令时遇到了问题,同样的问题。 spawn('google-chrome')
-
你能贴一个linux的例子吗
-
这很奇怪,我在 mac 中创建了一个包含所有命令的 json 文件,在 windows 和 linux 中,这些字符串以某种方式损坏。在linux和windows机器上改了,现在可以了。为什么?
标签: windows node.js child-process