Fireon on Electron app时出错:无法加载gRPC

问题描述 投票:0回答:1

我正在构建一个Electron应用程序,在renderer.js文件中,我正在使用Firebase Admin来获取Firestore数据。但是,每当我运行它时,它会在日志中返回此错误。

Error: Failed to load gRPC binary module because it was not installed for the current system
Expected directory: electron-v2.0-darwin-x64-unknown
Found: [node-v48-darwin-x64-unknown]
This problem can often be fixed by running "npm rebuild" on the current system

我试图运行“npm rebuild”,但它仍然没有解决它。我还尝试更新Firebase Admin和gRPC。

这是renderer.js文件中的代码...

// This file is required by the index.html file and will
// be executed in the renderer process for that window.
// All of the Node.js APIs are available in this process.

const admin = require('firebase-admin');

var serviceAccount = require('./credentials.json');

admin.initializeApp({
  credential: admin.credential.cert(serviceAccount),
  databaseURL: "https://mytestapp.firebaseio.com"
});

var db = admin.firestore();
const settings = {
  timestampsInSnapshots: true
};
db.settings(settings);

function LoadList() {

  db.collection("Orders").get().then(function(Collection){

    Collection.forEach(function(OrderDoc){
      console.log(OrderDoc.id)
    })

  }).catch(function(err){
    console.error(err);
  });

}

document.querySelector('#ListSec').addEventListener('click', LoadOrderList)

有任何想法吗?我一直试图解决这个问题几个小时,但似乎无法弄明白。

firebase electron google-cloud-firestore grpc firebase-admin
1个回答
2
投票

该错误消息表明已为Node安装了gRPC,而不是Electron。 Electron具有不同的二进制接口,因此需要专门为Electron安装二进制模块,如gRPC。您通常可以通过运行npm rebuild --runtime=electron --target=2.0.0(修改为匹配您要使用的Electron版本)来执行此操作。

© www.soinside.com 2019 - 2024. All rights reserved.