当前位置:网站首页>electron-builder打包不成功解决方法
electron-builder打包不成功解决方法
2022-08-02 03:27:00 【weixin_41779718】
安装smart-npm
npm install --global smart-npm --registry=https://registry.npm.taobao.org/
1、安装electron-builder(注意全局安装)
cnpm install -g electron-builder
cnpm install -g electron-package
2、在项目目录(my-project)执行打包命令
electron-builder
3、由于网络原因,各种包下载不下来,导致出错
electron-builder 在打包时会检测cache中是否有electron 包,如果没有的话会从github上拉去,在国内网络环境中拉取的过程大概率会失败,所以你可以自己去下载一个包放到cache目录里
例如在macos平台打包electron应用,执行 electron-builder --mac --x64
* clipboard git:(master) * npm run dist
> [email protected]1.0.0 dist /Users/xx/workspace/electron/clipboard
> electron-builder --mac --x64
• electron-builder version=22.3.2 os=18.7.0
• loaded configuration file=package.json ("build" field)
• writing effective config file=dist/builder-effective-config.yaml
• packaging platform=darwin arch=x64 electron=8.0.0 appOutDir=dist/mac
• downloading url=https://github.com/electron/electron/releases/download/v8.0.0/electron-v8.0.0-darwin-x64.zip size=66 MB parts=8
可以单独下载这个包 https://github.com/electron/electron/releases/download/v8.0.0/electron-v8.0.0-darwin-x64.zip, 放到~/Library/Caches/electron/ 目录下
如果下载不了就用淘宝的
https://npm.taobao.org/mirrors/electron/
各个平台的目录地址
Linux: $XDG_CACHE_HOME or ~/.cache/electron/
MacOS: ~/Library/Caches/electron/
Windows: %LOCALAPPDATA%/electron/Cache or ~/AppData/Local/electron/Cache/
我的windows目录是在
C:\Users\Administrator\AppData\Local\electron\Cache
常用参数
electron-builder配置文件写在package.json中的build字段中
"build": {
"appId": "com.example.app", // 应用程序id
"productName": "测试", // 应用名称
// 设置为 true 可以把自己的代码合并并加密
"asar": true,
"directories": {
"buildResources": "build", // 构建资源路径默认为build
"output": "dist" // 输出目录 默认为dist
},
"mac": {
"category": "public.app-category.developer-tools", // 应用程序类别
"target": ["dmg", "zip"], // 目标包类型
"icon": "build/icon.icns" // 图标的路径
},
"dmg": {
"background": "build/background.tiff or build/background.png", // 背景图像的路径
"title": "标题",
"icon": "build/icon.icns" // 图标路径
},
"win": {
// 打包成一个独立的 exe 安装程序
// 'target': 'nsis',
// 这个意思是打出来32 bit + 64 bit的包,但是要注意:这样打包出来的安装包体积比较大,所以建议直接打32的安装包。
// 'arch': [
// 'x64',
// 'ia32'
// ]
"target": ["nsis","zip"] // 目标包类型
},
"nsis": {
// 是否一键安装,建议为 false,可以让用户点击下一步、下一步、下一步的形式安装程序,如果为true,当用户双击构建好的程序,自动安装程序并打开,即:一键安装(one-click installer)
"oneClick": false,
// 允许请求提升。 如果为false,则用户必须使用提升的权限重新启动安装程序。
"allowElevation": true,
// 允许修改安装目录,建议为 true,是否允许用户改变安装目录,默认是不允许
"allowToChangeInstallationDirectory": true,
// 安装图标
"installerIcon": "build/installerIcon_120.ico",
// 卸载图标
"uninstallerIcon": "build/uninstallerIcon_120.ico",
// 安装时头部图标
"installerHeaderIcon": "build/installerHeaderIcon_120.ico",
// 创建桌面图标
"createDesktopShortcut": true,
// 创建开始菜单图标
"createStartMenuShortcut": true,
// electron中LICENSE.txt所需要的格式,并非是GBK,或者UTF-8,LICENSE.txt写好之后,需要进行转化,转化为ANSI
"license": "LICENSE.txt"
},
边栏推荐
- C language uses stack to calculate infix expressions
- xxe of CTF
- How to calculate the distance between two points on the earth (with formula derivation)
- 关于我的项目-实现一个数据库~
- 【泰山众筹】模式为什么一直都这么火热?是有原因的
- 对账、结账、错账更正方法、划线更正法、红字更正法、补充登记法
- 关于我的项目-微信小程序2(uniapp->wx小程序)
- 不懂“赚钱逻辑”,你永远都是社会最底层(广告电商)
- A network security guinea pig's learning path - scripting of advanced usage of nmap
- After Alibaba Cloud sets up domain name resolution redirection, I cannot use Chrome to access it
猜你喜欢
How to determine the direction based on two coordinate points on the map
如何在正则表达式里表达可能存在也可能不存在的内容?
自定义ViewGroup实现搜索栏历史记录流式布局
Cookie is used to collect the admin privileges CTF foundation problem
(3) string
文件包含漏洞
A network security guinea pig's learning path - scripting of advanced usage of nmap
对账、结账、错账更正方法、划线更正法、红字更正法、补充登记法
How to calculate the distance between two points on the earth (with formula derivation)
【一句话攻略】彻底理解JS中的回调(Callback)函数
随机推荐
面试必备:Android性能分析与优化实战进阶手册
深入了解为何面试官常说:你还没准备好,我不会录用你
解决flex布局warp自动换行下最后一行居中问题
[Hello World教程] 使用HBuilder和Uni-app 生成一个简单的微信小程序DEMO
元宇宙:为何互联网大佬纷纷涉足?元宇宙跟NFT是什么关系?
SGDP(1)——猜数字游戏
Laravel 验证唯一时排除修改时的数据
Microsoft Office安装全过程记录
Binder机制详解(三)
Summary of php function vulnerabilities
ES6 array extension methods map, filter, reduce, fill and array traversal for…in for…of arr.forEach
命令执行漏洞
管理会计(对内)指引、管理会计要素及其具体内容(可能考,考前记一下,推荐记一下四个大点即可)、
会计凭证概述、原始凭证、原始凭证的种类、原始凭证的基本内容、原始凭证的填制要求、原始凭证的审核
张量乘积—实验作业
redis未授权访问(4-unacc)
重点考:金融资产概述、交易性金融资产的概念、交易性金融资产的账务处理(取得、持有。出售)、
阿里技术官手码12W字面试小册
面试知识点整理:Skia 架构的场景渲染
二舅为什么能刷屏?这三件事对企业公关的启示