赞
踩
版本号:
electron: 29.1.4
@electron-forge/plugin-vite: ^7.3.0
@vitejs/plugin-vue: ^5.0.4
vite: ^5.0.12
执行 npm run make = electron-forge make 时:
An unhandled rejection has occurred inside Forge:
Error: /var/folders/8p/s4m7j1rn6z75zdkts44bvm980000gn/T/electron-packager/tmp-t0jfPi/Electron.app/Contents/Resources/app/node_modules/@vue/compiler-core/node_modules/.bin/parser: file "../../../../../../../../../../../../var/folders/8p/s4m7j1rn6z75zdkts44bvm980000gn/T/electron-packager/tmp-t0jfPi/Electron.app/Contents/Resources/app/node_modules/@babel/parser/bin/babel-parser.js" links out of the package
at Filesystem.insertLink (/Users/mac/工作/学习/electron-demo/node_modules/@electron/asar/lib/filesystem.js:106:13)
at handleFile (/Users/mac/工作/学习/electron-demo/node_modules/@electron/asar/lib/asar.js:132:20)
at next (/Users/mac/工作/学习/electron-demo/node_modules/@electron/asar/lib/asar.js:148:11)
at next (/Users/mac/工作/学习/electron-demo/node_modules/@electron/asar/lib/asar.js:149:12)
...
点击 node_modules/@electron/asar/lib/filesystem.js 查看:
104行
const link = path.relative(fs.realpathSync(this.src), path.join(parentPath, symlink))
看出不对劲了,relative的第一个参数用的fs.realpath,第二个却没用fs.realpath
解决办法:
把 node_modules/@electron/asar/lib/filesystem.js 104行改成 const link = path.relative(fs.realpathSync(this.src), fs.realpathSync(path.join(parentPath, symlink)))
然后安装 patch-package,执行 npx patch-package @electron/asar
后话:
根本原因在于 forge.config.js 的设置 packagerConfig.asar 为 true,但如果设成 false,虽然没有报错,但打包后的 exe/app 就运行不了,不知道为什么-_-
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。