First, I'll tell you about my work environment and start.
Desktop: Window10
Arch: AMD
WSL: Linux Ubuntu (Arch: AMD)
Compile Target: Linux (Arch: arm64)
Briefly, you are trying to run a cross-compile from a Windows environment to Linux (arm64).
If the error
You may need to re-bundle the app using Electron Packager's "executableName" option.
appears, it's probably a situation where you're trying to cross-compile, so let's find out more.
1. Reason
There are two compilation methods described on the official page of electron-forge.
https://www.electronforge.io/configuration
1. Trying to compile by writing config in package.json
2. Attempting to compile by creating forge.config.js in the root directory
The error occurred when attempting to compile by writing config in 1. package.json.
If you look at the existing package.json
"config": {
"forge": {
"packagerConfig": {},
"makers": [
{
"name": "@electron-forge/maker-squirrel",
"config": {
"name": "my_electron_app"
}
},
{
"name": "@electron-forge/maker-zip",
"platforms": [
"darwin"
]
},
{
"name": "@electron-forge/maker-deb",
"config": {}
},
{
"name": "@electron-forge/maker-rpm",
"config": {}
}
]
}
},
In this way, the values for forge are written in the config.
Error - You may need to re-bundle the app using Electron Packager's "executableName" option.
I tried to run it in "packagerConfig":{} based on this error, but I got the same error again.
2. Solved
So to solve this problem
2. Set forge.config.js to make executableName properly configured.
https://www.electronforge.io/configuration
Before that, as explained in electron-forge, there should be no config.forge in package.json, but it is said that forge.config.js is used in the root directory, so let's delete the config of package.json written above.
Below is the forge.config.js I defined.
// forge.config.js
module.exports = {
packagerConfig: {
// set config executableName
executableName: "my-electron-app",
icon: './icon',
},
makers: [
{
name: '@electron-forge/maker-deb',
executableName: "my-electron-app",
config: {
options: {
icon: './icon.png',
name: 'my-electron-app',
productName: 'my-electron-app'
}
}
}
],
// set output directory name
buildIdentifier: 'my-electron-app-build',
}
Since the package asked you to set the executableName property, it will set the packageConfig.executableName.
For reference, the parts related to platform, arch, dir, out, and electronVersion in forge.config.js are not defined and are used through cli.
3. Execution
Now, let's type make cli and check the result
// compile to platform->host, arch->arm64
npm run make -- --arch=arm64
It's compiled well!!!
For reference, information on electron-forge's cli can be obtained here.
https://www.electronforge.io/cli