package.json
{
"type": "module",
"name": "demo",
"version": "1.0.0",
"main": "main.js",
"scripts": {
"start": "chcp 65001 && electron .",
"dev": "chcp 65001 && nodemon --exec electron .",
"pack": "electron-builder --dir",
"build": "electron-builder"
},
"build": {
"productName": "邓瑞编程",
"appId": "com.dengruicode.demo",
"win": {
"icon": "resource/images/code.ico",
"target": [
{
"target": "nsis",
"arch": ["x64"]
}
]
},
"nsis": {
"oneClick": false,
"perMachine": true,
"allowToChangeInstallationDirectory": true
}
},
"keywords": [],
"author": "邓瑞",
"license": "ISC",
"description": "",
"devDependencies": {
"electron": "^32.0.1",
"electron-builder": "^25.0.5"
}
}
注
"build": {
"productName": "邓瑞编程", //应用名称
"appId": "com.dengruicode.demo", //应用程序的唯一标识符
"win": { //Windows 平台
"icon": "resource/images/code.ico", //应用程序的图标路径
"target": [ //构建目标
{
"target": "nsis", //使用 nsis 创建安装程序
"arch": ["x64"] / 构建 x64 架构的版本
}
]
},
"nsis": { //nsis 安装程序的相关配置
"oneClick": false, //不是一键安装, 会显示安装向导界面
"perMachine": true, //将应用程序安装到所有用户的全局位置
"allowToChangeInstallationDirectory": true //允许用户更改安装目录
}
}
"author": "邓瑞", //作者
图标报错
image D:\workspace\electron\demo\resource\images\code.ico must be at least 256x256
解决方法
code.ico 像素至少 256x256