electron-builder: nsis can't install the app for all users on some PC
- Version: 20.44.4
- Target: windows
I have created an installer using electron-builder settings below:
"build": {
"productName": "MyApp",
"appId": "com.MyApp",
"extraResources": [
{
"from": "./someApp/someApp.exe",
"to": "someApp.exe"
},
{
"from": "./someApp/someApp.config.yaml",
"to": "someApp.config.yaml"
}
],
"directories": {
"output": "build"
},
"files": [
"dist/electron/**/*"
],
"win": {
"icon": "build/icons/icon.ico",
"requestedExecutionLevel": "requireAdministrator"
},
"nsis": {
"oneClick": false,
"perMachine": true,
"allowToChangeInstallationDirectory": true
}
},
I have installed the app on few machines and there were two PC where I couldn’t install it. Here is what I get:

it says: Installation Aborted. Setup was not completed successfully.
I have no idea why this happens, and how to fix it. Does anybody know why it might happen? This problem appears on two machines out of 7 I have tested so far. Both run windows 10.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 10
- Comments: 30 (6 by maintainers)
I can confirm the issue. Upgrading electron-builder
and changing the nsis configuration
results in problems with installing the new package over an existing installation:

The new installer might work on a second try, which will also result in a non-updated + broken installation entry in the Windows programs list.
@Zver64 IMO this should be reopened
Ok, seems like the above is not the complete story, there seems to be an issue with the installation directory depending if a one-click unattended installer or an attended installer is created.
I recently added this section to my package.json build config:
Without the above section, an unattended one-click installer is created which on a clean installation installs the app into:
\AppData\Local\Programs\<packagejson.name>\so unless you use the “build.extraMetadata” option to change the “name” property, multiple apps with different “productName” values overwrite each other despite creating separate registry entries and desktop shortcuts (which seem to be based on the productName.When adding the above config which creates the attended installer, on a clean install the app is installed into:
\AppData\Local\Programs\<packagejson.build.productName>allowing separate app installations to be created without having to change the "name " property.If the app is installed first using the one-click installer and then installed over the top using the attended installer, the attended installer detects an existing installation at
\AppData\Local\Programs\<packagejson.name>\, then removes the contents of the directory and installs the app at:\AppData\Local\Programs\<packagejson.name>\<packagejson.build.productName>instead of\AppData\Local\Programs\<packagejson.build.productName>uninstalling the app then leaves behind an empty\AppData\Local\Programs\<packagejson.name>\directory but does correctly remove the registry entries.I was not able to reproduce the issue by performing the above steps, so likely it was caused by the changes i had made over time.
The installation aborts immediately after clicking the “Install” button on the choose install location dialog.
I noticed when the installer detects an existing installation making the app install as an upgrade, the installation path was listed as
\AppData\Local\Programs\<packagejson.name>\<packagejson.build.productName>however the<packagejson.name>part did not match what i currently have in my package.json file, it instead was matching the existing installation directory path found in the registry atHKEY_CURRENT_USER\Software\<installation-guid>\InstallLocationAt some point in the past i implemented testing and staging builds by changing the package.json “name” and “build.productName” properties. Initially i was only changing the “build.productName” and 'build.appId" properties which did not actually change the installation directory and add-remove-programs / registry entry until i found out about “build.extraMetadata” which also allowed the 'name" property to be changed. It looks like i had an existing installation with the intended productName but the name left unchanged, making the installer detect the productName and try to use an incorrect installation directory found in the registry.
I tried installing as a fresh installation, deleting the app dir from
%USERPROFILE%\AppData\Local\Programs\<packagejson.name>did not make the installer think that the app is not installed, uninstalling from add-remove programs also did not do the trick. It looks at the registry key inHKEY_CURRENT_USER\Software\<installation-guid>which seems to have been left behind during the uninstall. Once that is deleted it installs as a fresh installation.Installing as a fresh installation solved the issue and i was also unable to recreate the issue by upgrading. I tested it by creating 3 builds using 20.38.5, 20.43.0 and 20.44.4 and them installing them in sequence.
It seems that the issue was caused by the presence of a previous installation built using a different configuration of package.json name and build.productName settings. I think some work needs to be done to improve the error handling here as it does not fail nicely. I also could not find any installation logs, although it didn’t spend too long looking, anyone know where to find them?
I’ve found a solution. If you’re on Windows, open
Programs and Features, look for your app and click uninstall. Windows had the application in cache and NSIS doesn’t let you install the app if it already exists in cache.Any updates regarding this?
same problem here. I just want to install the program to the program file folder rather than the AppData folder