I was trying to use nodegit and was running into trouble. I followed the install instructions on the README and then tried the examples there, but was getting errors for anything beyond requiring the package.
For now it seems you can't use the version of nodegit that is published to npm.
npm install nodegit
That will install version 0.1.4. Which seems to not work. Here's an example of what would happen.
// test.js
var open = require('nodegit').Repository.open;node test.jswhich would give the following:
/Users/tyler/Desktop/wut/test.js:1
odule, __filename, __dirname) { var open = require('nodegit').Repository.open;
^
TypeError: Cannot read property 'open' of undefined
at Object.<anonymous> (/Users/tyler/Desktop/wut/test.js:1:103)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
What you need is nodegit version 0.2.0. To get that, you can install the package from the master branch on Github. You'll need a package.json. Here's what I'm doing.
// package.json
...
"devDependencies": {
"nodegit": "git+ssh://[email protected]:nodegit/nodegit#master"
}
...
Once that's in place, run npm install again. Wait quite a while and then the nodegit example above–and the others–should work.
Oh cool, didn't know you could install it like that in package.json. Thanks!