electron TodoList网页应用打包成linux deb、AppImage应用
这里用的是windows的wsl的ubuntu环境https://i-blog.csdnimg.cn/direct/b8bc8e7e81fb4219a4543507fc085d2f.pngelectron应用打包linux应用需要linux下打包,这里用windows的wsl的ubuntu环境进行操作
1)linux ubuntu安装nodejs、electron
安装nodejs:
sudo apt update
sudo apt upgrade
##快捷安装
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
安装完验证
https://i-blog.csdnimg.cn/direct/9e2b62c9b7f245888fb8bff5bb0d09af.png
安装electron:
##安装cnpm
sudo npm install -g cnpm --registry=https://registry.npmmirror.com
cnpm install --save-dev electron
cnpm install electron-builder --save-dev
https://i-blog.csdnimg.cn/direct/f200662ca5dd4fd3a2b515d62232b8b0.png
2、electron打包linux应用
参考:
TodoList网页:https://cnloong.blog.csdn.net/article/details/140648621
TodoList打包文件夹内容根本都是上面和windows打包exe一样,只更改了package.json文件
https://i-blog.csdnimg.cn/direct/b4b058990a87421c9f63fa2def2e79cc.png
新package.json内容:
linux下需要author、homepage、maintainer参数,否则会报错
{
"name": "todolist-app",
"version": "1.0.0",
"main": "main.js",
"homepage": "https://example.com",
"author": {
"name": "Your Name",
"email": "your.email@example.com"
},
"build": {
"appId": "com.yourcompany.todolist",
"mac": {
"category": "public.app-category.productivity"
},
"win": {
"icon": "icons/icon.png",
"target": [
"nsis"
]
},
"linux": {
"target": [
"AppImage",
"deb"
],
"category": "Utility",
"maintainer": "Your Name <your.email@example.com>"
}
},
"scripts": {
"start": "electron .",
"build": "electron-builder --linux"
},
"keywords": [],
"license": "ISC",
"description": "",
"devDependencies": {
"electron": "^31.2.1",
"electron-builder": "^24.13.3"
},
"dependencies": {}
}
打包过程:
1)在windows的wsl的ubuntu环境进入对应windows目录TodoList下
一般/mnt下就是映射的windows的目录
https://i-blog.csdnimg.cn/direct/cad43be9aac74de1a962c0fef0abaf6e.png
https://i-blog.csdnimg.cn/direct/5273a3a833c6471f8c9a46bef6319a18.png
2)build
npm run build
https://i-blog.csdnimg.cn/direct/9a500ed2e53d4b3c9f31342922fade09.png
3)打包完成
在dist文件夹下可以看到linux平台的deb、AppImage安装包
https://i-blog.csdnimg.cn/direct/4bc45dd315fc4c5d88cb06db67a7fa8a.png
dist\linux-unpacked 下是免安装包
https://i-blog.csdnimg.cn/direct/7120d827f863466e9f1e5345a5d19ba7.png
ubuntu桌面检察
直接cmd进入linux-unpacked 目录下执行
./todolist-app --no-sandbox
如果不加–no-sandbox会报错
https://i-blog.csdnimg.cn/direct/8fc3fddf97b84999b3793eb1f3dc5108.png
https://i-blog.csdnimg.cn/direct/f4c0a49b6f9344fd92efbb91b1201a87.png
TodoList 运行结果
https://i-blog.csdnimg.cn/direct/92dae9bdef44460baaac4adbaf75dabb.png
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页:
[1]