当前位置:网站首页>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"
},
边栏推荐
- Sensitive information leakage
- PHP hash加密与解密
- centos8 安装搭建php环境
- 同态加密:CKKS原理之旋转(Rotation)
- 元宇宙是一个炒作的科幻概念,还是互联网发展的下半场?
- 学IT,找工作——移除链表元素
- Offensive and defensive world - novice MISC area 1-12
- 自定义view实现半圆弧进度条
- After Alibaba Cloud sets up domain name resolution redirection, I cannot use Chrome to access it
- 阿里技术官手码12W字面试小册
猜你喜欢
随机推荐
考(重点理解哪些属于其他货币资金)、其他货币资金的内容、其他货币资金的账务处理(银行汇票存款、银行本票存款、信用卡存款、信用证保证金存款、存出投资款、外埠存款)
会计凭证概述、原始凭证、原始凭证的种类、原始凭证的基本内容、原始凭证的填制要求、原始凭证的审核
阿里技术官手码12W字面试小册
关于我的大创、论文~
【一句话攻略】彻底理解JS中的回调(Callback)函数
加密数字货币前传:从大卫·乔姆到中本聪
Dcat Admin 关闭代码生成器 登录指定地址
PALISADE:CKKS的使用
挖矿是什么意思?矿工都做了什么?
机器学习1
laravel-admin 列表图片点击放大
File upload vulnerability
Larave 自定义公共函数以及引入使用
CTF-Neting Cup Past Topics
解决flex布局warp自动换行下最后一行居中问题
Laravel 登录,中间件和路由分组
hackmyvm-random walkthrough
自定义view实现半圆弧进度条
账务处理程序、记账凭证账务处理程序、汇总记账凭证账务处理程序、科目汇总表账务处理程序、会计信息化概述、信息化环境下会计账务处理的基本要求(此章出1道小题)
命令执行漏洞









