【发布时间】:2025-12-08 05:15:01
【问题描述】:
我想为 windows、mac 和 linux 创建电子应用程序安装程序,但目前它只是创建 .exe 文件:
还有一些解压后的目录和其他一些我什至不知道为什么需要的文件,因为 .exe 文件正在安装我的应用程序并创建桌面快捷方式,我什至不需要这些额外的文件来让应用程序工作.
换句话说 - 当我只是复制 .exe 并在其他机器上运行时,它会成功安装,因此为什么我什至需要这些其他文件?
所以它可以在 Windows 上正常工作,但它不会创建任何我可以在 macOS 和 linux 上运行的文件,比如 .dmg。
这是我的 package.json
{
"name": "screenrecorder",
"version": "1.0.0",
"description": "Electron application to record screen",
"main": "./src/js/main/index.js",
"scripts": {
"start": "electron ./src/js/main/index.js",
"compile:sass": "node-sass src/style/scss/main.scss src/style/css/output.css -w",
"build": "electron-builder"
},
"repository": {
"type": "git",
"url": "https://github.com/d0peCode/screenRecorder"
},
"build": {
"appId": "screenrecorder",
"mac": {
"category": "your.app.category.type",
"target": "dmg"
}
},
"author": "Borys Tyminski",
"license": "ISC",
"homepage": "https://github.com/d0peCode/screenRecorder#readme",
"dependencies": {
"angular": "^1.6.5",
"angular-route": "^1.6.5"
},
"devDependencies": {
"electron": "^6.0.2",
"electron-builder": "^21.2.0",
"node-sass": "^4.9.2"
}
}
这是我在运行npm run build后从终端获取的日志
C:\Users\Borys\Documents\work\screenRecorder\desktop>npm run build
screenrecorder@1.0.0 build >C:\Users\Borys\Documents\work\screenRecorder\desktop
电子制造商
• electron-builder 版本=21.2.0 os=10.0.18362
• 加载的配置文件=package.json(“构建”字段)
• 编写有效的配置文件=dist\builder-effective-config.yaml
• 打包平台=win32 arch=x64 electron=6.0.6 appOutDir=dist\win-unpacked
• 使用默认 Electron 图标原因=未设置应用程序图标
• building target=nsis file=dist\screenrecorder Setup 1.0.0.exe archs=x64 oneClick=true perMachine=false
• 积木图blockMapFile=dist\screenrecorder 设置1.0.0.exe.blockmap
为什么它不创建 macOS 安装程序?以及如何做到这一点?
【问题讨论】:
-
您使用什么操作系统进行开发?我们还可以看到您的构建过程的日志输出吗?
-
我用的是windows 10,我会用日志编辑问题
标签: macos electron exe electron-builder dmg