Reputation: 26142
git is installed on windows and works from any directory (it is in System path)
var child_process = require('child_process');
child_process.exec('git --version', function(err, stdout, stderr) {
// stdout is correct - git version 1.7.11.msysgit.1
// but err is not null
// err is [Error: Command failed: ] killed: false, code: 1, signal: null }
}
What can cause this?
Upvotes: 1
Views: 1505
Reputation: 3682
I had this issue using Windows 7 with msysgit. Two things seem to solve the issue.
First, verify that your Path
system variable includes a path to the Git bin directory, and not the cmd directory:
C:\Program Files (x86)\Git\bin
Next, verify you have a recent version of msysgit. I've verified the issue as solved with version 1.8.4-preview
:
https://code.google.com/p/msysgit/downloads/list
Restart your shell and try again.
Upvotes: 3
Reputation: 11052
As a workaround you can pass {env:{PATH:"C:\path to\node"}}
as the options argument to process.exec(cmd, opts, callback)
as described in docs. I am surprised that the Windows path doesn't carry over but have no explanation why.
Upvotes: 1