【发布时间】:2017-01-29 19:05:21
【问题描述】:
我在使用 nodegit 时遇到此错误,我不确定是否是我不知道如何使用电子遥控器的错,还是 nodegit 的问题。为了以防万一,我做了file an issue。
在我的 main.js 电子文件中,我可以毫无问题地使用 nodegit。
在网站上,我尝试使用带有remote 的nodegit。我得到一个错误。我的代码:
var remote = require('electron').remote;
var pathToRepo = remote.require('path').resolve(currentRepoDir);
remote.require('nodegit').Repository.open(pathToRepo).then(function(repo){
console.log(repo);
});
我收到错误:
Uncaught TypeError: require(...).remote.require(...).Repository.open is not a function
为什么open 不是函数?
【问题讨论】:
-
你为什么要使用
remote? remote module 本质上使用 RMI,它存在许多缺点,通常不需要。是否有特殊原因不需要直接使用“path”和“nodegit”,而不需要远程? -
@inukshuk 我会尝试更新问题。
remote的用例是什么? -
在我看来,
remote的主要用例是当您需要访问一些仅对主进程可用的 Electron 模块(例如,remote.app)时——有无法直接在您的渲染器进程中要求这些。但是节点模块是可用的,所以我真的没有理由在主进程中创建它们并通过 RMI 访问它们,除非你想以某种方式在进程之间共享状态。
标签: javascript node.js electron nodegit