node.jsshelljs

Why do I get a NullReferenceException when using shelljs to clone a git repo?


I am attempting to write a fairly simple nodejs program that needs to clone a git repo.

var shell = require('shelljs');
shell.exec('git clone http://mybitbuck.et/scm/myproject/myrepo.git');

Throws an error as follows, and then seems to hang without exiting forever:

fatal: NullReferenceException encountered.
Object reference not set to an instance of an object.

There is no additional output or stack trace, not even a line number. What is going on, and how can I get it working, or at least get more information about what is happening and why?

I know I could use nodegit or similar instead of using the shell but I think I would benefit from understanding what is happening here HOW to address situations where output is so sparse.


Solution

  • I solved this. It is related to the version of git for windows (2.19.1) that I was running, and updating to the newest version removed the error.

    I eventually found the right search term combination that lead me to this bug: https://github.com/git-for-windows/git/issues/1868