的package.json
{
//some other config
"repository": "git@gitintsrv.domain.com/UserName/RepoName",
"scripts": {
"build": "build --win",
"ship": "build --win -p always"
}
}
的电子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)中指定“repository”。 请参阅https://electron.build/configuration/publish
错误在哪里?
答案 0 :(得分:0)
这曾经是Electron Builder 19x的一个特定问题,此问题已得到解决:
https://github.com/electron-userland/electron-builder/issues/2785
答案 1 :(得分:0)
我知道可能为时已晚,但是如果您像我一样来到这里,这就是我的解决方法:
将此添加到您的 package.json
"build": {
"publish": [{
"provider": "github",
"host": "github.<<DOMAIN>>.com",
"owner": "<<USER>>",
"repo": "<<NAME OF YOUR REPO (ONLY THE NAME)>>",
"token": "<<ACCESS TOKEN>>"
}]
}
我认为问题在于电子无法解析公司github网址或其他内容。
***********编辑:
在根文件夹中创建一个electronic-builder.yml,内容如下
appId: com.corporate.AppName
publish:
provider: github
token: <<ACCESS TOKEN>>
host: github.corporate.com
owner: <<User/ Org>>
repo: <<repo name>>
别忘了将此文件包含在您的.gitignore中