官网的地址:快速入门 | Electron 当我们按照官网的步骤打包的时候,会遇到很多坑,最常见的就是链接网络下载地址失败、或者找不到指定module等,解决办法如下:以npm为例: 1.配置npm下载环境:在~/.npmrc里做如下设置
electron_mirror="https://npm.taobao.org/mirrors/electron/" (该文件为隐藏文件,在命令行用vim进入即可,然后添加这句话) 2.各种依赖的版本用如下配置,亲测有效:测试日期是2021/10/29日 package.json用如下替换:
{
"name": "my-electron-app024906",
"version": "1.0.0",
"description": "hhhh",
"main": "main.js",
"author": "wkk",
"license": "MIT",
"scripts": {
"start": "electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make"
},
"dependencies": {
"electron-compile": "^6.4.3",
"electron-squirrel-startup": "^1.0.0"
},
"devDependencies": {
"@electron-forge/cli": "^6.0.0-beta.61",
"@electron-forge/maker-deb": "^6.0.0-beta.61",
"@electron-forge/maker-rpm": "^6.0.0-beta.61",
"@electron-forge/maker-squirrel": "^6.0.0-beta.61",
"@electron-forge/maker-zip": "^6.0.0-beta.61",
"electron": "15.3.0"
},
"config": {
"forge": {
"packagerConfig": {},
"makers": [
{
"name": "@electron-forge/maker-squirrel",
"config": {
"name": "my_electron_app024906"
}
},
{
"name": "@electron-forge/maker-zip",
"platforms": [
"darwin"
]
},
{
"name": "@electron-forge/maker-deb",
"config": {}
},
{
"name": "@electron-forge/maker-rpm",
"config": {}
}
]
}
}
}
3.其余文件和官网一模一样。
4.输入cnpm i? ?然后npm run make 就大功告成
|