I'm using electron and I have the following in my main process
import * as Git from "nodegit";
console.log("NodeGit version is:", Git.version);
console.log("The HARD reset type has the id", Git.Reset.TYPE.HARD);
When I yarn start as usual, I get the following output
NodeGit version is: 0.27.0
App threw an error during load
TypeError: Cannot read property 'TYPE' of undefined
at Object../src/main.ts ([redacted-project-dir]\.webpack\main\index.js:17543:57)
at __webpack_require__ ([redacted-project-dir]\.webpack\main\index.js:21:30)
at [redacted-project-dir]\.webpack\main\index.js:85:18
at Object.<anonymous> ([redacted-project-dir]\.webpack\main\index.js:88:10)
at Module._compile (internal/modules/cjs/loader.js:968:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:986:10)
at Module.load (internal/modules/cjs/loader.js:816:32)
at Module._load (internal/modules/cjs/loader.js:728:14)
at Module._load (electron/js2c/asar.js:717:26)
at Function.Module._load (electron/js2c/asar.js:717:26)
This can be reproduced in a fresh project created with
yarn create electron-app my-electron-webpack-typescript --template=typescript-webpack
Note that I get identical results when I do these in my renderer process using ipc.
I found a discussion here with a similar problem where the solution seemed to be to set the build target to ES5 instead of ES6 as the Reset module has a function called default
which might cause an ES6 code not being able to import it. I'm not sure if this could even be the case.
But I don't know how could I specify the compile target to ES5. (I'm using webpack and I also seem to be using babel.)