Study & Project ✏️/Bug & Report 🐞

[electron-forge Error] You may need to re-bundle the app using Electron Packager's "executableName" option.

JM 2023. 5. 4. 16:26
반응형

우선 제 작업 환경을 알려주고 시작하겠습니다.

 

Desktop: Window10

Arch: AMD

WSL: Linux Ubuntu (Arch: AMD)

 

Target Compile: Linux (Arch: arm64)

 


 

 

간략하게 설명하자면 윈도우 환경에서 Linux(arm64)로 크로스컴파일을 진행하려고 하는 상황입니다.

 

You may need to re-bundle the app using Electron Packager's "executableName" option. 라는 오류가 나왔다면 아마 크로스컴파일을 시도하는 상황일 경우일텐데 이제부터 자세히 알아보자

 

1. 문제 이유

electron-forge의 공식 페이지에서 설명하는 컴파일 방법은 총 두 가지다.

https://www.electronforge.io/configuration

 

Configuration - Electron Forge

This property can be used to identify different build configurations. Normally, this property is set to the channel the build will release to, or some other unique identifier. For example, common values are prod and beta. This identifier can be used in con

www.electronforge.io

1. package.json에 config를 적어서 컴파일을 시도하는 것

2. forge.config.js를 root 디렉토리에 만들어서 컴파일을 시도하는 것

 

해당 에러는 1. package.json에 config를 적어서 컴파일을 시도했을때 발생했다.

 

기존 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": {}
        }
      ]
    }
  },

이렇게 config 안에 forge에 대한 값들을 적어두고 있다.

 

Error - You may need to re-bundle the app using Electron Packager's "executableName" option.

해당 에러를 토대로 "packagerConfig": {} 에 넣어서 실행을 해봤지만 또 같은 오류가 나왔다.

 

2. 해결방법

그래서 해당 문제를 해결하기 위해

2. forge.config.js를 설정해서 executableName을 제대로 config하도록 만들었다.

https://www.electronforge.io/configuration

 

Configuration - Electron Forge

This property can be used to identify different build configurations. Normally, this property is set to the channel the build will release to, or some other unique identifier. For example, common values are prod and beta. This identifier can be used in con

www.electronforge.io

 

그 전에 electron-forge에서 설명하기로는 package.json에 config.forge가 없어야지만 root디렉토리에서 forge.config.js를 사용한다고 되어 있으므로 위에 적힌 package.json의 config는 삭제해주도록 하자.

 

아래는 내가 정의한 forge.config.js이다.

// 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',
}

packager에서 executableName 프로퍼티를 설정해주라고 했으므로 packagerConfig.execitableName을 설정해준다.

참고로 forge.config.js에서 platform, arch, dir, out, electronVersion에 관한 부분은 정의하지 않고 cli를 통해 사용한다고 한다.

 

3. 실행

그러면 이제 make cli를 입력해서 결과를 확인해보자

// compile to platform->host, arch->arm64
npm run make -- --arch=arm64

잘 컴파일 됐다!!!

 

참고로 electron-forge의 cli에 관한 정보는 여기서 얻을 수 있다.

https://www.electronforge.io/cli

 

CLI - Electron Forge

Target architecture to make for. Defaults to the arch that you're running on (the "host" arch). Allowed values are: "ia32", "x64", "armv7l", "arm64", "universal", or "mips64el". Multiple values should be comma-separated.

www.electronforge.io