2017-09-27 17 views
1

nodejsを使用してコマンドプロンプトでコマンドを実行します。 https://dzone.com/articles/understanding-execfile-spawn-exec-and-fork-in-nodeに基づい
は、私は上記のコードは、ENOENTエラーをスローexec vs execFile nodeJs

child_process.execFile('protractor', ['./src/convertedJs/tempProtractorconfig.js'], (err, stdout, stderr) => {} 

を用います。
しかし、私は

child_process.exec('protractor ./src/convertedJs/tempProtractorconfig.js', (err,stdout,stderr) => {}` 

を実行すると、すべてが正常に動作します。
誰かが何が起こっているか説明できますか? nodejs v9.5.0で

+0

ないほどあなたのケースでは、それは非常に奇妙では、あなたが同じディレクトリからそれらの両方を実行していますか? –

+0

yepss..iは同じdirで動作しています –

答えて

0

は、execはファイルLIB/child_process.js

exports.exec = function(command /*, options, callback*/) { 
var opts = normalizeExecArgs.apply(null, arguments); 
return exports.execFile(opts.file, opts.options, opts.callback); 

}で以下のように定義されます。意味

、最終的にあなたのコマンドをexcuteするexecコールexecFileexecFileは失敗したがexec

関連する問題