electron / forge

:electron: A complete tool for building and publishing Electron applications
https://electronforge.io
MIT License
6.51k stars 521 forks source link

From template=vite-typescript, run package error #3689

Closed XianZhengquan closed 2 months ago

XianZhengquan commented 2 months ago

Pre-flight checklist

Electron Forge version

7.4.0

Electron version

32.0.2

Operating system

macOS 14.6.1

Last known working Electron Forge version

No response

Expected behavior

run package success

Actual behavior

run package error

image

Steps to reproduce

  1. npm init electron-app@latest my-app -- --template=vite-typescript

  2. run yarn package

Additional information

No response

bdlr2 commented 2 months ago

Exact same issue with template webpack-typescript. Trying to build for Linux ARM64.

I suspect the reason is the bump from dependency @electron/asar v3.2.10 to 3.2.11 Temporary fix is to add these lines to package.json

    "overrides": {
        "@electron-forge/cli" : {
            "@electron-forge/core" : {
                "@electron/packager": {
                    "@electron/asar": "3.2.10"
                }
            }
        }
    }

Log:

node@7c67c5e7da0f:~$ npm init electron-app@latest my-new-app -- --template=webpack-typescript

> npx
> create-electron-app my-new-app --template=webpack-typescript

✔ Locating custom template: "webpack-typescript"
✔ Initializing directory
✔ Preparing template
✔ Initializing template
✔ Installing template dependencies
node@7c67c5e7da0f:~$ cd ./my-new-app/
node@7c67c5e7da0f:~/my-new-app$ npm run package -- --platform=linux --arch=arm64

> my-new-app@1.0.0 package
> electron-forge package --platform=linux --arch=arm64

✔ Checking your system
  ✔ Running generateAssets hook
✔ Preparing to package application
✔ Running packaging hooks
  ✔ Running generateAssets hook
  ✔ Running prePackage hook
    ✔ [plugin-webpack] Preparing webpack bundles
      ✔ Preparing native dependencies [0.4s]
      ✔ Building webpack bundles [7s]
❯ Packaging application
  ❯ Packaging for arm64 on linux
    ✔ Copying files
    ✔ Preparing native dependencies [26s]
    ✖ Finalizing package
      › Cannot read properties of undefined (reading 'createPackageWithOptions')
◼ Running postPackage hook

An unhandled rejection has occurred inside Forge:
TypeError: Cannot read properties of undefined (reading 'createPackageWithOptions')
at LinuxApp.asarApp (/home/node/my-new-app/node_modules/@electron/packager/src/platform.ts:248:16)
    at async LinuxApp.buildApp (/home/node/my-new-app/node_modules/@electron/packager/src/platform.ts:153:5)
    at async LinuxApp.initialize (/home/node/my-new-app/node_modules/@electron/packager/src/platform.ts:144:7)
    at async LinuxApp.create (/home/node/my-new-app/node_modules/@electron/packager/src/linux.ts:14:5)
    at async Promise.all (index 0)
    at async packager (/home/node/my-new-app/node_modules/@electron/packager/src/packager.ts:246:20)
XianZhengquan commented 2 months ago

Got the fix here @bdlr2 https://github.com/electron/asar/pull/325

georgexu99 commented 2 months ago

This can be resolved by upgrading electron/asar in the dependency tree 🙇