I build an electron app with auto-update enabled. After running the application on Windows, I got an error emitted by my application which is "Error: Can not find Squirrel". After look into the code of electron project for finding the error message.
checkForUpdates () {
const url = this.updateURL;
if (!url) {
return this.emitError(new Error('Update URL is not set'));
}
if (!squirrelUpdate.supported()) {
return this.emitError(new Error('Can not find Squirrel'));
}
this.emit('checking-for-update');
squirrelUpdate.checkForUpdate(url, (error, update) => {
if (error != null) {
return this.emitError(error);
}
if (update == null) {
return this.emit('update-not-available');
}
this.updateAvailable = true;
this.emit('update-available');
squirrelUpdate.update(url, (error) => {
if (error != null) {
return this.emitError(error);
}
const { releaseNotes, version } = update;
// Date is not available on Windows, so fake it.
const date = new Date();
this.emit('update-downloaded', {}, releaseNotes, version, date, this.updateURL, () => {
this.quitAndInstall();
});
});
});
}
And after check the function squirrelUpdate.supported(). I know it is because the install location has no file "Update.exe".
I use electron-builder to generate my application and there is no Update.exe in unpacked packaged directory. How do I generate the Update.exe file?
The block of configuration of electron-builder in package.json is blow:
"win": {
"target": [
"nsis"
],
"defaultArch": "x64",
"verifyUpdateCodeSignature": false
},
How to solve the problem? Thanks.