I am new to Electron and Electron-Packager, this is my first app using them. I'm still a student btw, and this is for my project.
I have an app, already finished and ready to be packaged. It uses ReactJS, Redux, and React-Router for the renderer and it needs Sequelize to transact with a sqlite database.
I use ES6, but I bundle all my files for the renderer into one file.min.js and file.min.js for the main process.
How do I use electron-builder to
main.sqlite then run all the migrations for that database using sequelize.Windows — set nsis.oneClick to false. To implement custom logic in the installer and uninstaller — See Custom NSIS script https://www.electron.build/configuration/nsis
I use ES6, but I bundle all my files for the renderer into one file.min.js and file.min.js for the main process.
If you don't bundle node modules — move all dependencies to devDependencies to ensure that it will be not packed into app. Please see docs about files option.
And please use latest electron-builder. Also, maybe useful for you — https://webpack.electron.build
@develar I migrated to electron-builder 19.27.7, now it's telling me that my config which worked with the previous version is incorrect.
Error: Configuration is invalid.
- configuration has an unknown property 'allowToChangeInstallationDirectory'. These properties are valid:
object { afterPack?, apk?, appId?, appImage?, appx?, artifactName?, asar?, asarUnpack?, beforeBuild?, buildDependenciesFromSource?, buildVersion?, compression?, copyright?, deb?, detectUpdateChannel?, directories?, dmg?, electronCompile?, electronDist?, electronDownload?, electronVersion?, extends?, extraFiles?, extraMetadata?, extraResources?, fileAssociations?, files?, forceCodeSigning?, freebsd?, icon?, linux?, mac?, mas?, muonVersion?, nodeGypRebuild?, npmArgs?, npmRebuild?, npmSkipBuildFromSource?, nsis?, nsisWeb?, p5p?, pacman?, pkg?, portable?, productName?, protocols?, publish?, releaseInfo?, rpm?, snap?, squirrelWindows?, target?, win? }
Configuration Options
For typos: please correct them.
For loader options: webpack 2 no longer allows custom properties in configuration.
Loaders should be updated to allow passing options via loader options in module.rules.
Until loaders are updated one can use the LoaderOptionsPlugin to pass these options to the loader:
plugins: [
new webpack.LoaderOptionsPlugin({
// test: /\.xxx$/, // may apply this only for some modules
options: {
allowToChangeInstallationDirectory: ...
}
})
]
How to fix:
1. Open https://electron.build/configuration/configuration
2. Search the option name on the page.
* Not found? The option was deprecated or not exists (check spelling).
* Found? Check that the option in the appropriate place. e.g. "title" only in the "dmg", not in the root.
at C:\Users\aprilpineda\Documents\projects\desktop\experiments\1-lendingInfoSys\node_modules\read-config-file\src\main.ts:128:11
at Generator.next (<anonymous>)
at C:\Users\aprilpineda\Documents\projects\desktop\experiments\1-lendingInfoSys\node_modules\fs-extra-p\node_modules\jsonfile\index.js:46:5
at C:\Users\aprilpineda\Documents\projects\desktop\experiments\1-lendingInfoSys\node_modules\graceful-fs\graceful-fs.js:78:16
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:503:3)
From previous event:
at validateConfig (C:\Users\aprilpineda\Documents\projects\desktop\experiments\1-lendingInfoSys\node_modules\read-config-file\out\main.js:133:22)
at C:\Users\aprilpineda\Documents\projects\desktop\experiments\1-lendingInfoSys\node_modules\electron-builder\src\util\config.ts:103:3
at Generator.next (<anonymous>)
From previous event:
at validateConfig (C:\Users\aprilpineda\Documents\projects\desktop\experiments\1-lendingInfoSys\node_modules\electron-builder\out\util\config.js:100:22)
at C:\Users\aprilpineda\Documents\projects\desktop\experiments\1-lendingInfoSys\node_modules\electron-builder\src\packager.ts:146:11
at Generator.next (<anonymous>)
From previous event:
at Packager.build (C:\Users\aprilpineda\Documents\projects\desktop\experiments\1-lendingInfoSys\node_modules\electron-builder\out\packager.js:257:11)
at C:\Users\aprilpineda\Documents\projects\desktop\experiments\1-lendingInfoSys\node_modules\electron-builder\src\builder.ts:286:40
at Generator.next (<anonymous>)
at build (C:\Users\aprilpineda\Documents\projects\desktop\experiments\1-lendingInfoSys\node_modules\electron-builder\out\builder.js:69:21)
at loadEnv.then (C:\Users\aprilpineda\Documents\projects\desktop\experiments\1-lendingInfoSys\node_modules\electron-builder\src\cli\cli.ts:49:4)
From previous event:
at build (C:\Users\aprilpineda\Documents\projects\desktop\experiments\1-lendingInfoSys\node_modules\electron-builder\out\builder.js:69:21)
at loadEnv.then (C:\Users\aprilpineda\Documents\projects\desktop\experiments\1-lendingInfoSys\node_modules\electron-builder\out\cli\cli.js:155:79)
at runCallback (timers.js:800:20)
at tryOnImmediate (timers.js:762:5)
at processImmediate [as _immediateCallback] (timers.js:733:5)
From previous event:
at Object.args [as handler] (C:\Users\aprilpineda\Documents\projects\desktop\experiments\1-lendingInfoSys\node_modules\electron-builder\out\cli\cli.js:155:68)
at Object.self.runCommand (C:\Users\aprilpineda\Documents\projects\desktop\experiments\1-lendingInfoSys\node_modules\electron-builder\node_modules\yargs\lib\command.js:233:22)
at Object.Yargs.self._parseArgs (C:\Users\aprilpineda\Documents\projects\desktop\experiments\1-lendingInfoSys\node_modules\electron-builder\node_modules\yargs\yargs.js:1018:24)
at Object.get [as argv] (C:\Users\aprilpineda\Documents\projects\desktop\experiments\1-lendingInfoSys\node_modules\electron-builder\node_modules\yargs\yargs.js:927:19)
at Object.<anonymous> (C:\Users\aprilpineda\Documents\projects\desktop\experiments\1-lendingInfoSys\node_modules\electron-builder\out\cli\cli.js:151:418)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Function.Module.runMain (module.js:605:10)
at startup (bootstrap_node.js:158:16)
at bootstrap_node.js:575:3
here is my configuration
"build": {
"oneClick": false,
"perMachine": true,
"allowElevation": true,
"allowToChangeInstallationDirectory": true,
"deleteAppDataOnUninstall": true,
"appId": "com.aprilmintacpineda.lims",
"productName": "Lending Information Management System",
"buildVersion": "1.0.83",
"files": [
"app/**/*",
"models/**/*",
"node_modules/**/*"
],
"extraFiles": [
"database/main.sqlite"
]
}
Following the docs -> https://www.electron.build/configuration/nsis <- my config seems fine, based on the message I received, it's telling me that deleteAppDataOnUninstall is an unknown key.
PS: When the app is packaged, I want to allow the user to choose where he wants to install the app. I also want to allow multiple users of that machine to install the app separate from other users, i.e., per user install.
allowToChangeInstallationDirectory and other nsis options must be under nsis key, not in the root object.
Most helpful comment
allowToChangeInstallationDirectory and other nsis options must be under nsis key, not in the root object.