electron / forge

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

An error is reported after vue is imported #3548

Open 188 opened 8 months ago

188 commented 8 months ago

Pre-flight checklist

Electron Forge version

7.3.1

Electron version

29.1.5

Operating system

macOS 14.3.1

Last known working Electron Forge version

No response

Expected behavior

yarn make can run properly with no error reported:

Actual behavior

yarn run v1.22.19 $ electron-forge package ✔ Checking your system ⠙ Preparing to package application ◼ Running packaging hooks ✔ Preparing to package application ❯ Running packaging hooks ✔ Running generateAssets hook ✔ Preparing to package application ❯ Running packaging hooks ✔ Running generateAssets hook ❯ Running prePackage hook ⠸ [plugin-vite] Building vite bundles ◼ Packaging application ◼ Running postPackage hook ✔ Preparing to package application ✔ Preparing to package application ❯ Running packaging hooks ✔ Running generateAssets hook ❯ Running prePackage hook ✔ Preparing to package application ✔ Running packaging hooks ✔ Running generateAssets hook ✔ Running prePackage hook ✔ [plugin-vite] Building vite bundles ❯ Packaging application ❯ Packaging for arm64 on darwin ✔ Copying files ✔ Preparing native dependencies [0.5s] ✖ Finalizing package › /var/folders/f3/_c8y2b7575gb8zwp0k3fy4cc0000gn/T/electron-packager/tmp-LAvMjM/Electron.app/Contents/Resources/a… ◼ Running postPackage hook

An unhandled rejection has occurred inside Forge: Error: /var/folders/f3/_c8y2b7575gb8zwp0k3fy4cc0000gn/T/electron-packager/tmp-LAvMjM/Electron.app/Contents/Resources/app/node_modules/@vue/compiler-core/node_modules/.bin/parser: file "../../../../../../../../../../../../var/folders/f3/_c8y2b7575gb8zwp0k3fy4cc0000gn/T/electron-packager/tmp-LAvMjM/Electron.app/Contents/Resources/app/node_modules/@babel/parser/bin/babel-parser.js" links out of the package at Filesystem.insertLink (/Users/steven/data/test/my-new-app21/node_modules/@electron/asar/lib/filesystem.js:106:13) at handleFile (/Users/steven/data/test/my-new-app21/node_modules/@electron/asar/lib/asar.js:132:20) at next (/Users/steven/data/test/my-new-app21/node_modules/@electron/asar/lib/asar.js:148:11) at next (/Users/steven/data/test/my-new-app21/node_modules/@electron/asar/lib/asar.js:149:12) at processTicksAndRejections (node:internal/process/task_queues:95:5) at async MacApp.asarApp (/Users/steven/data/test/my-new-app21/node_modules/@electron/packager/src/platform.ts:245:5) at async MacApp.buildApp (/Users/steven/data/test/my-new-app21/node_modules/@electron/packager/src/platform.ts:150:5) at async MacApp.initialize (/Users/steven/data/test/my-new-app21/node_modules/@electron/packager/src/platform.ts:141:7) at async MacApp.create (/Users/steven/data/test/my-new-app21/node_modules/@electron/packager/src/mac.ts:435:5) at async Promise.all (index 0) at async packager (/Users/steven/data/test/my-new-app21/node_modules/@electron/packager/src/packager.ts:246:20) error Command failed with exit code 1.

Steps to reproduce

1、npm init electron-app@latest my-vue-app -- --template=vite 2、npm install vue 3、npm install --save-dev @vitejs/plugin-vue 4、yarn 5、yarn make

Additional information

No response

dietrich-stein commented 8 months ago

I seem to be seeing a related issue running electron-forge package --platform darwin while building on macOs.

An unhandled rejection has occurred inside Forge: Error: /var/folders/wl/pm6gbjcn1gl79xh6vjznq7k80000gn/T/electron-packager/tmp-NNy4Lz/Electron.app/Contents/Resources/app/node_modules/@babel/helper-compilation-targets/node_modules/.bin/semver: file "../../../../../../../../../../../../var/folders/wl/pm6gbjcn1gl79xh6vjznq7k80000gn/T/electron-packager/tmp-NNy4Lz/Electron.app/Contents/Resources/app/node_modules/@babel/helper-compilation-targets/node_modules/semver/bin/semver.js" links out of the package at Filesystem.insertLink (/Users/dietrichstein/deepmojo-electron-vite/node_modules/@electron/asar/lib/filesystem.js:106:13) at handleFile (/Users/dietrichstein/deepmojo-electron-vite/node_modules/@electron/asar/lib/asar.js:132:20) at next (/Users/dietrichstein/deepmojo-electron-vite/node_modules/@electron/asar/lib/asar.js:148:11) at next (/Users/dietrichstein/deepmojo-electron-vite/node_modules/@electron/asar/lib/asar.js:149:12) at processTicksAndRejections (node:internal/process/task_queues:95:5) at async MacApp.asarApp (/Users/dietrichstein/deepmojo-electron-vite/node_modules/@electron/packager/src/platform.ts:245:5) at async MacApp.buildApp (/Users/dietrichstein/deepmojo-electron-vite/node_modules/@electron/packager/src/platform.ts:150:5) at async MacApp.initialize (/Users/dietrichstein/deepmojo-electron-vite/node_modules/@electron/packager/src/platform.ts:141:7) at async MacApp.create (/Users/dietrichstein/deepmojo-electron-vite/node_modules/@electron/packager/src/mac.ts:435:5) at async Promise.all (index 0) at async packager (/Users/dietrichstein/deepmojo-electron-vite/node_modules/@electron/packager/src/packager.ts:246:20)

Presumably, this could be reproducible on LuanRoger/electron-shadcn but I have not tried.

I tried several things including (1) a packageAfterPrune() hook trying to delete the file assuming it is being left behind due to a versioning mismatch (2) derefSymlinks: false, (3) vite-plugin-commonjs-externals, (4) optimizeDeps.exclude, (5) externalizeDepsPlugin from electron-vite. No combination of workaround using any them were fruitful for me. Currently looking at what electron-vite really has to offer as an alternative.

Edit: Reproduced the OP report using the steps provided:

An unhandled rejection has occurred inside Forge:
Error: /var/folders/wl/pm6gbjcn1gl79xh6vjznq7k80000gn/T/electron-packager/tmp-S2cbBg/Electron.app/Contents/Resources/app/node_modules/@vue/compiler-core/node_modules/.bin/parser: file "../../../../../../../../../../../../var/folders/wl/pm6gbjcn1gl79xh6vjznq7k80000gn/T/electron-packager/tmp-S2cbBg/Electron.app/Contents/Resources/app/node_modules/@babel/parser/bin/babel-parser.js" links out of the package
at Filesystem.insertLink
188 commented 8 months ago

Is there a solution? Now how to operate can make or package normally. Or do you need to wait for a new release? Maybe downgrade to 7.3.0?

Nick22nd commented 8 months ago

I encountered the same issue(links out of the package), and I resolved it by removing yarn.lock and node_modules. Switch to npm:

rm -rf node_modules yarn.lock
npm i
tclxsr commented 7 months ago

I encountered the same issue(links out of the package), and I resolved it by removing yarn.lock and node_modules. Switch to npm:

rm -rf node_modules yarn.lock
npm i

Its worked for me!

188 commented 7 months ago

After many tests, the problem was found, as long as the vue was introduced and then packaged, the error was reported, and there was no problem when the vue was removed. Is there any feasible solution?

188 commented 7 months ago

https://www.electronforge.io/guides/framework-integration/vue-3#integrating-vue-3-code Follow the document An error occurs after npm install vue. No problem after npm uninstall vue

188 commented 7 months ago

God can help with that. Thank you

188 commented 7 months ago

@Nick22nd @dietrich-stein @anaisbetts