alex8088 / electron-vite

Next generation Electron build tooling based on Vite 新一代 Electron 开发构建工具,支持源代码保护
https://electron-vite.org
MIT License
3.27k stars 139 forks source link

pnpm build fail, windows 目录文件路径过长导致构建错误 #574

Open NHZEX opened 1 month ago

NHZEX commented 1 month ago

Describe the bug

构建错误

  • electron-builder  version=24.13.3 os=10.0.22631
  • loaded configuration  file=F:\_REMOVE_\test123000000000000001\electron-builder.yml
  • writing effective config  file=dist\builder-effective-config.yaml
  • skipped dependencies rebuild  reason=npmRebuild is set to false
  • packaging       platform=win32 arch=x64 electron=31.3.0 appOutDir=dist\win-unpacked
  • building        target=nsis file=dist\dev-client-1.0.0-setup.exe archs=x64 oneClick=true perMachine=false
  ⨯ C:\Users\_REMOVE_\AppData\Local\electron-builder\Cache\nsis\nsis-3.0.4.1\Bin\makensis.exe process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
Exit code:
1
Output:
Command line defined: "APP_ID=com.electron.app"
Command line defined: "APP_GUID=_REMOVE_"
Command line defined: "UNINSTALL_APP_KEY=_REMOVE_"
Command line defined: "PRODUCT_NAME=dev-client"
Command line defined: "PRODUCT_FILENAME=dev-client"
Command line defined: "APP_FILENAME=dev-client"
Command line defined: "APP_DESCRIPTION=An Electron application with Vue and TypeScript"
Command line defined: "VERSION=1.0.0"
Command line defined: "PROJECT_DIR=F:\_REMOVE_\test123000000000000001"
Command line defined: "BUILD_RESOURCES_DIR=F:\_REMOVE_\test123000000000000001\build"
Command line defined: "APP_PACKAGE_NAME=dev-client"
Command line defined: "MUI_ICON=F:\_REMOVE_\test123000000000000001\build\icon.ico"
Command line defined: "MUI_UNICON=F:\_REMOVE_\test123000000000000001\build\icon.ico"
Command line defined: "APP_64=F:\_REMOVE_\test123000000000000001\dist\dev-client-1.0.0-x64.nsis.7z"
Command line defined: "APP_64_NAME=dev-client-1.0.0-x64.nsis.7z"
Command line defined: "APP_64_HASH=_REMOVE_"
Command line defined: "APP_64_UNPACKED_SIZE=300029"
Command line defined: "COMPANY_NAME=example.com"
Command line defined: "APP_INSTALLER_STORE_FILE=dev-client-updater\installer.exe"
Command line defined: "COMPRESSION_METHOD=7z"
Command line defined: "ONE_CLICK"
Command line defined: "RUN_AFTER_FINISH"
Command line defined: "SHORTCUT_NAME=dev-client"
Command line defined: "UNINSTALL_DISPLAY_NAME=dev-client"
Command line defined: "RECREATE_DESKTOP_SHORTCUT"
Command line defined: "ESTIMATED_SIZE=300028"
Command line defined: "COMPRESS=auto"
Command line defined: "BUILD_UNINSTALLER"
Command line defined: "UNINSTALLER_OUT_FILE=F:\_REMOVE_\test123000000000000001\dist\__uninstaller-nsis-dev-client.exe"
Processing config: C:\Users\_REMOVE_\AppData\Local\electron-builder\Cache\nsis\nsis-3.0.4.1\nsisconf.nsh
Processing script file: "<stdin>" (UTF8)

Error output:
!include: could not open file: "F:\_REMOVE_\test123000000000000001\node_modules\.pnpm\app-builder-lib@24.13.3_dmg-builder@24.13.3_electron-builder-squirrel-windows@24.13.3__electr_jhkj5etvr5lkpiqd5wtx2uh6ge\node_modules\app-builder-lib\templates\nsis\include\allowOnlyOneInstallerInstance.nsh"
Error in script "<stdin>" on line 87 -- aborting creation process
  failedTask=build stackTrace=Error: C:\Users\_REMOVE_\AppData\Local\electron-builder\Cache\nsis\nsis-3.0.4.1\Bin\makensis.exe process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
Exit code:
1
Output:
Command line defined: "APP_ID=com.electron.app"
Command line defined: "APP_GUID=_REMOVE_"
Command line defined: "UNINSTALL_APP_KEY=_REMOVE_"
Command line defined: "PRODUCT_NAME=dev-client"
Command line defined: "PRODUCT_FILENAME=dev-client"
Command line defined: "APP_FILENAME=dev-client"
Command line defined: "APP_DESCRIPTION=An Electron application with Vue and TypeScript"
Command line defined: "VERSION=1.0.0"
Command line defined: "PROJECT_DIR=F:\_REMOVE_\test123000000000000001"
Command line defined: "BUILD_RESOURCES_DIR=F:\_REMOVE_\test123000000000000001\build"
Command line defined: "APP_PACKAGE_NAME=dev-client"
Command line defined: "MUI_ICON=F:\_REMOVE_\test123000000000000001\build\icon.ico"
Command line defined: "MUI_UNICON=F:\_REMOVE_\test123000000000000001\build\icon.ico"
Command line defined: "APP_64=F:\_REMOVE_\test123000000000000001\dist\dev-client-1.0.0-x64.nsis.7z"
Command line defined: "APP_64_NAME=dev-client-1.0.0-x64.nsis.7z"
Command line defined: "APP_64_HASH=_REMOVE_"
Command line defined: "APP_64_UNPACKED_SIZE=300029"
Command line defined: "COMPANY_NAME=example.com"
Command line defined: "APP_INSTALLER_STORE_FILE=dev-client-updater\installer.exe"
Command line defined: "COMPRESSION_METHOD=7z"
Command line defined: "ONE_CLICK"
Command line defined: "RUN_AFTER_FINISH"
Command line defined: "SHORTCUT_NAME=dev-client"
Command line defined: "UNINSTALL_DISPLAY_NAME=dev-client"
Command line defined: "RECREATE_DESKTOP_SHORTCUT"
Command line defined: "ESTIMATED_SIZE=300028"
Command line defined: "COMPRESS=auto"
Command line defined: "BUILD_UNINSTALLER"
Command line defined: "UNINSTALLER_OUT_FILE=F:\_REMOVE_\test123000000000000001\dist\__uninstaller-nsis-dev-client.exe"
Processing config: C:\Users\_REMOVE_\AppData\Local\electron-builder\Cache\nsis\nsis-3.0.4.1\nsisconf.nsh
Processing script file: "<stdin>" (UTF8)
     Error output:
!include: could not open file: "F:\_REMOVE_\test123000000000000001\node_modules\.pnpm\app-builder-lib@24.13.3_dmg-builder@24.13.3_electron-builder-squirrel-windows@24.13.3__electr_jhkj5etvr5lkpiqd5wtx2uh6ge\node_modules\app-builder-lib\templates\nsis\include\allowOnlyOneInstallerInstance.nsh"
Error in script "<stdin>" on line 87 -- aborting creation process
         at ChildProcess.<anonymous> (F:\_REMOVE_\test123000000000000001\node_modules\.pnpm\builder-util@24.13.1\node_modules\builder-util\src\util.ts:252:14)
    at Object.onceWrapper (node:events:632:26)
    at ChildProcess.emit (node:events:517:28)
    at ChildProcess.cp.emit (F:\_REMOVE_\test123000000000000001\node_modules\.pnpm\cross-spawn@7.0.3\node_modules\cross-spawn\lib\enoent.js:34:29)
    at maybeClose (node:internal/child_process:1098:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:303:5)

解决方案: .npmrc 目前还需要添加该设置才能解决兼容性。

node-linker=hoisted

pnpm: 9.6.0

资料: https://github.com/nodejs/node/issues/50753#issuecomment-2039791858

Electron-Vite Version

2.3.0

Electron Version

31.3.0

Vite Version

5.3.1

Validations

alex8088 commented 1 month ago

脚手架默认已有配置

NHZEX commented 1 month ago

脚手架默认已有配置

我初始化脚手架的配置只有

electron_mirror=https://npmmirror.com/mirrors/electron/
electron_builder_binaries_mirror=https://npmmirror.com/mirrors/electron-builder-binaries/
shamefully-hoist=true

补上这个才成功的

node-linker=hoisted