简体   繁体   中英

Nodegit and Electron not working together

I am getting this error with nodegit, and I am not sure if it is my fault for not knowing how to work with electron remote or it is a problem with nodegit. I did file an issue just in case.

In my main.js file for electron I can use nodegit without any issue.

On the web site I try to use nodegit with remote . I get an error. My code:

var remote = require('electron').remote;
var pathToRepo = remote.require('path').resolve(currentRepoDir);
remote.require('nodegit').Repository.open(pathToRepo).then(function(repo){
  console.log(repo);
}); 

I am getting the error:

Uncaught TypeError: require(...).remote.require(...).Repository.open is not a function

Why is open not a function?

Why are you using remote.require ?

remote.require('path')

Just use:

require('path')

require works in the render process too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM