当前位置:   article > 正文

electron使用electron-forge创建的项目,结合vite+vue,报错An unhandled rejection has occurred inside Forge_an unhandled rejection has occurred inside forge:

an unhandled rejection has occurred inside forge: requesterror: certificate

版本号:

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 就运行不了,不知道为什么-_-

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/一键难忘520/article/detail/965026
推荐阅读
相关标签
  

闽ICP备14008679号