Vue3+Electron构建报错
使用环境
"Node":"21.6.2"
"@vue/cli-service": "~5.0.0",
"electron": "^13.0.0",
问题一
报错
background.js from Terser
Error: error:0308010C:digital envelope routines::unsupported
at new Hash
at Object.createHash
at E:\前端\assist\node_modules\vue-cli-plugin-electron-builder\node_modules\webpack\node_modules\terser-webpack-plugin\dist\index.js:217:37
at Array.forEach
at TerserPlugin.optimizeFn
at _next0
at eval
at processTicksAndRejections
原因
用了高版本的node.js
解决
给NODE_OPTIONS添加环境变量--openssl-legacy-provider,低版本的不需要,默认忽略ssl验证
set NODE_OPTIONS=--openssl-legacy-provider
问题二
报错
Error output:
!include: could not find: "E:\前端\assist\node_modules\app-builder-lib\templates\nsis\include\StdUtils.nsh"
Error in script "<stdin>" on line 1 -- aborting creation process
at ChildProcess.<anonymous>
at Object.onceWrapper
at ChildProcess.emit
at ChildProcess.cp.emit
at maybeClose
at Process.ChildProcess._handle.onexit {
exitCode: 1,
alreadyLogged: false,
code: 'ERR_ELECTRON_BUILDER_CANNOT_EXECUTE'
}
原因
路径有中文路径
解决
切换项目目录给copy到个全英路径的位置
问题三
报错
打开页面全白

原因
路由模式用的history
解决
路由模式切换成hash模式
问题四
报错
<router-view>标签不生效
原因
不清楚为什么会这样 反正我这个版本打包后 electron不会进入”/“路径下 但是在本地访问的时候会
解决
在App.vue中直接push到/
import { useRouter } from "vue-router";
const router = useRouter();
router.push(`/`);
要注意的是router.back();路由跳转我这边也不生效了,需要都替换成push('/')。
问题五
报错
• cannot get, wait error=Get "https://service.electron.build/find-build-agent?no-cache=1it6rqj": dial tcp 51.15.76.176:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
attempt=0
waitTime=2
• cannot get, wait error=Get "https://service.electron.build/find-build-agent?no-cache=1it6rqj": dial tcp 51.15.76.176:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
attempt=1
waitTime=4
• cannot get, wait error=Get "https://service.electron.build/find-build-agent?no-cache=1it6rqj": dial tcp 51.15.76.176:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
attempt=2
waitTime=6
⨯ Get "https://service.electron.build/find-build-agent?no-cache=1it6rqj": dial tcp 51.15.76.176:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
win跨平台构建linux从service.electron.build下载资源失败,换代理也没用
原因
这个站点service.electron.build似乎在2020年就关闭,一直也没人来修这个玩意
解决
换linux主机构建或者采用docker的容器进行构建 ISSUES:https://github.com/electron-userland/electron-build-service/issues/9