cynicaldevil cynicaldevil - 2 months ago 23x
Javascript Question

Async operations with nodegit on electron not working

I am working on a project using electron and nodegit, and I recently updated my dependencies. After solving the compatibility issues, I found two versions of nodegit and electron that work. But upon testing it, I found that async nodegit operations fail, while the synchronous ones work fine. Here's a code example that does not work:

const pathToRepo = require('path').resolve(path);
.then((repo) => {
.catch( (err) => {

Upon executing it, the promise returns an error which is caught by the catch block, and upon outputting the value on the console it simple displays
, and gives no additional information.

Also, I had updated node from 5 to 6.3 before updating my dependencies.


electron-prebuilt: 0.37.8

nodegit: 0.13.0

After updating:

electron-prebuilt: 1.2.1

nodegit: 0.14.1

EDIT: Solved by adding an npm script:

"rebuild": "npm rebuild --runtime=electron --target=1.2.1 disturl= --build-from-source",

and running
npm run rebuild


nodegit contains a native NodeJS module, native modules must be rebuilt to target the Electron version you use them with. Instructions for rebuilding native modules can be found at