github ssh public key not found with node.js child_process.spawn() on windows, but visible on child_process.exec()

This code works on Windows and on Mac OS X:

var exec = require( 'child_process' ).exec
exec( 'git clone git@github.com:user/myrepo.git' )

But this code returns an "Access denied(publickey)" error from git when running on Windows, but not on Mac OS X:

var spawn = require( 'child_process' ).spawn
 ,  child = spawn( 'git', [ 'clone', 'git@github.com:user/myrepo.git' ], { env: process.env } )

child.on.stderr( 'data', function( data ) { 
  console.log( data.toString() )
})

I assume in spawn i'm losing my connection to ~/.ssh... but I thought sending in process.env would work. By the way, the git clone commands work fine on Windows when typed into the command prompt directly.

Anything obviously wrong?

Not a Node problem, but a git problem. Upgraded git on Windows from 1.7.11 to 1.8.3 and the spawn worked.

I suppose the environment variables are lost in a classic node.js spaw() function, especially HOME (which isn't defined by default in windows, and is necessary for ssh to find its keys)

Maybe a spawn like win-spawn would work better:

Spawn for node.js but in a way that works regardless of which OS you're using. Use this if you want to use spawn with a JavaScript file.

It works by explicitly invoking node on windows.
It also shims support for environment variable setting by attempting to parse the command with a regex.
Since all modification is wrapped in if (os === 'Windows_NT'), it can be safely used on non-windows systems and will not break anything.