autoUpdater.setFeedURL 不是函数
autoUpdater.setFeedURL is not a function
我正在尝试在 Electron 应用程序中实现 windows 自动更新功能(这可能会导致我早逝),但出现此错误。
这是URL我为了测试而通过的
编辑:我的电子应用程序使用两个 package.json 结构,这段代码在我的应用程序>main.js 文件
const feedURL = 'C:\Users\p00009970\Desktop\update_test';
autoUpdater.setFeedURL(feedURL);
autoUpdater.checkForUpdates();
EDIT2:感谢@JuanMa,我能够让它工作。这是代码。
// auto update functionality
const {autoUpdater} = require('electron')
// local file system example: const feedURL = 'C:\Users\john\Desktop\updates_folder';
// network file system example: const feedURL = '\\serverName\updates_folder';
const feedURL = '\\serverName\updates_folder';
app.on('ready', () => {
autoUpdater.setFeedURL(feedURL);
// auto update event listeners, these are fired as a result of autoUpdater.checkForUpdates();
autoUpdater.addListener("update-available", function(event) {
});
autoUpdater.addListener("update-downloaded", function(event, releaseNotes, releaseName, releaseDate, updateURL) {
//TODO: finess this a tad, as is after a few seconds of launching the app it will close without warning
// and reopen with the update which could confuse the user and possibly cause loss of work
autoUpdater.quitAndInstall();
});
autoUpdater.addListener("error", function(error) {
});
autoUpdater.addListener("checking-for-update", function(event) {
});
autoUpdater.addListener("update-not-available", function(event) {
});
// tell squirrel to check for updates
autoUpdater.checkForUpdates();
})
您是否正确包含了 autoUpdater 模块?
const {autoUpdater} = require('electron')
如果是这样,请尝试在应用 'ready' 事件之后执行代码。
app.on('ready', () => {
const feedURL = 'C:\Users\p00009970\Desktop\update_test';
autoUpdater.setFeedURL(feedURL);
autoUpdater.checkForUpdates();
})
我正在尝试在 Electron 应用程序中实现 windows 自动更新功能(这可能会导致我早逝),但出现此错误。
这是URL我为了测试而通过的
编辑:我的电子应用程序使用两个 package.json 结构,这段代码在我的应用程序>main.js 文件
const feedURL = 'C:\Users\p00009970\Desktop\update_test';
autoUpdater.setFeedURL(feedURL);
autoUpdater.checkForUpdates();
EDIT2:感谢@JuanMa,我能够让它工作。这是代码。
// auto update functionality
const {autoUpdater} = require('electron')
// local file system example: const feedURL = 'C:\Users\john\Desktop\updates_folder';
// network file system example: const feedURL = '\\serverName\updates_folder';
const feedURL = '\\serverName\updates_folder';
app.on('ready', () => {
autoUpdater.setFeedURL(feedURL);
// auto update event listeners, these are fired as a result of autoUpdater.checkForUpdates();
autoUpdater.addListener("update-available", function(event) {
});
autoUpdater.addListener("update-downloaded", function(event, releaseNotes, releaseName, releaseDate, updateURL) {
//TODO: finess this a tad, as is after a few seconds of launching the app it will close without warning
// and reopen with the update which could confuse the user and possibly cause loss of work
autoUpdater.quitAndInstall();
});
autoUpdater.addListener("error", function(error) {
});
autoUpdater.addListener("checking-for-update", function(event) {
});
autoUpdater.addListener("update-not-available", function(event) {
});
// tell squirrel to check for updates
autoUpdater.checkForUpdates();
})
您是否正确包含了 autoUpdater 模块?
const {autoUpdater} = require('electron')
如果是这样,请尝试在应用 'ready' 事件之后执行代码。
app.on('ready', () => {
const feedURL = 'C:\Users\p00009970\Desktop\update_test';
autoUpdater.setFeedURL(feedURL);
autoUpdater.checkForUpdates();
})