electron打包方案
- electron-builder
electron-builder
1. 安装 electron-builder
npm install --save-dev electron-builder
2.修改 package.json
,添加一条scripts
命令和build
配置。
"build": "electron-builder --win" // 打包命令
"build": {"productName": "PowerPAL","directories": {"output": "out"},"win": {"icon": "./ico/logo.ico","target": [{"target": "nsis","arch": ["x64","ia32"]}]},"nsis": {"oneClick": false,"allowElevation": true,"allowToChangeInstallationDirectory": true,"installerIcon": "./ico/logo.ico","uninstallerIcon": "./ico/logo.ico","installerHeaderIcon": "./ico/logo.ico","createDesktopShortcut": true,"createStartMenuShortcut": true,"shortcutName": "PowerPAL"}}
3.执行build命令
npm run build
问题
在初次运行打包命令electron-builder的时候,会下载一些依赖,依赖不大,但问题是会一直卡着
解决方法
1、下载electron-v31.1.0-win32-x64文件失败
直接下载上面的 github 链接指向的文件,下载完成后不用解压,直接放在C:\Users\Administrator\AppData\Local\electron\Cache
目录下
2、下载 winCodeSign-2.6.0 文件失败
方法同上,下载完解压到 C:\Users\Administrator\AppData\Local\electron-builder\Cache\winCodeSign
目录下
3、下载electron-v33.2.1-win32-ia32.zip 文件失败
方法同上,下载完成后不用解压,直接放在C:\Users\Administrator\AppData\Local\electron\Cache
目录下
4、下载 nsis-3.0.4.1.7z 文件失败
方法同上,下载完解压到C:\Users\Administrator\AppData\Local\electron-builder\Cache\nsis
目录下
4、下载 nsis-resources-3.4.1.7z 文件失败
方法同上,下载完解压到C:\Users\Administrator\AppData\Local\electron-builder\Cache\nsis\nsis-resources-3.4.1
目录下