Electron Forge构建Linux deb安装包失败,报错:cannot make for linux and target deb: the maker declared that it cannot run on linux
Electron Forge构建Linux deb安装包失败,报错:cannot make for linux and target deb: the maker declared that it cannot run on linux
嗨,我之前也碰到过一模一样的问题,咱们一步步来搞定它!
这个报错的核心原因是你的配置里重复指定了deb构建逻辑,导致Electron Forge的内部流程混乱了。下面是具体的修复步骤:
1. 清理冲突的配置项
你在packagerConfig里设置了linux.target: 'deb',但同时又在makers数组里配置了@electron-forge/maker-deb——这俩功能重叠了,Forge不知道该用哪个来处理deb包构建,所以抛出了错误。
把packagerConfig里的linux节点删掉,修改后的这块配置应该是:
packagerConfig: { asar: true },
2. 确保Linux环境有构建deb的依赖
很多虚拟机默认没装deb打包必需的工具,这也会导致这类“无法运行”的隐性报错。打开终端执行以下命令安装依赖:
sudo apt-get update && sudo apt-get install fakeroot dpkg
3. 重新执行构建命令
现在可以运行构建命令,指定Linux平台即可:
npm run make -- --platform linux
如果还是有问题,可以检查下@electron-forge/maker-deb的版本是否和Electron Forge核心版本一致——版本不兼容也会出奇怪的问题。更新到对应版本的命令:
npm install @electron-forge/maker-deb@latest
这样操作后,应该就能顺利生成你想要的.deb安装包啦!
备注:内容来源于stack exchange,提问作者nicolabaesso
相关产品推荐
相关产品推荐

