简体   繁体   English

Nodegit和Electron无法一起工作

[英]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. 我在使用nodegit时遇到此错误,并且我不确定是由于我不知道如何使用电子遥控器进行操作是我的错,还是因为nodegit出现了问题。 I did file an issue just in case. 我确实提出了一个问题 ,以防万一。

In my main.js file for electron I can use nodegit without any issue. 在我的电子main.js文件中,我可以毫无问题地使用nodegit。

On the web site I try to use nodegit with remote . 在网站上,我尝试将nodegit与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? 为什么open不起作用?

Why are you using remote.require ? 为什么要使用remote.require

remote.require('path')

Just use: 只需使用:

require('path')

require works in the render process too. 在渲染过程中也require工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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