【问题标题】:electron-builder cannot find git repository although specifyingelectron-builder 虽然指定了,但找不到 git 存储库
【发布时间】:2020-07-29 22:44:25
【问题描述】:

package.json

{
    //some other config
    "repository": "git@gitintsrv.domain.com/UserName/RepoName",
    "scripts": {
        "build": "build --win",
        "ship": "build --win -p always"
    }
}


electron-builder.yml

appId: com.xorchat.app.windows
publish:
    provider: github
    token: some_token

electron.js

const { app, BrowserWindow, ipcMain } = require('electron');
const { autoUpdater } = require("electron-updater");
let win; // this will store the window object

// creates the default window
function createDefaultWindow() {
    win = new BrowserWindow({ width: 900, height: 680 });
    win.loadURL(`file://${__dirname}/src/index.html`);
    win.on('closed', () => app.quit());
    return win;
}

// when the app is loaded create a BrowserWindow and check for updates
app.on('ready', function() {
    createDefaultWindow()
    autoUpdater.checkForUpdates();
});

// when the update has been downloaded and is ready to be installed, notify the BrowserWindow
autoUpdater.on('update-downloaded', (info) => {
    win.webContents.send('updateReady')
});

// when receiving a quitAndInstall signal, quit and install the new version ;)
ipcMain.on("quitAndInstall", (event, arg) => {
    autoUpdater.quitAndInstall();
})

当我运行 npm run build 时,我收到此错误。

错误:无法通过 .git/config 检测存储库。请在 package.json (https://docs.npmjs.com/files/package.json#repository) 中指定“存储库”。 请看https://electron.build/configuration/publish

哪里出错了?

【问题讨论】:

    标签: github windows-10 electron electron-builder


    【解决方案1】:

    我知道这可能为时已晚,但如果你最终像我一样来到这里,我是这样解决的:

    将此添加到您的 package.json

      "build": {
        "publish": [{
           "provider": "github",
           "host": "github.<<DOMAIN>>.com",
           "owner": "<<USER>>",
           "repo": "<<NAME OF YOUR REPO (ONLY THE NAME)>>",
           "token": "<<ACCESS TOKEN>>"
         }]
      }
    

    我认为问题是电子无法解析公司 github url 或其他东西。

    *********** 编辑:

    在根目录下创建一个electron-builder.yml,内容如下

    appId: com.corporate.AppName
    publish:
      provider: github
      token: <<ACCESS TOKEN>>
      host: github.corporate.com
      owner: <<User/ Org>>
      repo: <<repo name>>
    

    不要忘记将此文件包含在您的 .gitignore 中

    【讨论】:

    • 你的 package.json 文件可能会被推送到 github 仓库,所以在这里粘贴你的 token 不是最好的主意
    【解决方案2】:

    这曾经是 Electron Builder 19x 的一个特定问题,现已修复:

    https://github.com/electron-userland/electron-builder/issues/2785

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-02
      • 2019-10-17
      • 1970-01-01
      • 1970-01-01
      • 2020-02-23
      • 2017-06-27
      • 1970-01-01
      • 2012-08-11
      相关资源
      最近更新 更多