折腾了一天在macos上安装虚拟机安装debian操作系统,然后又折腾了一天在debian上打包,踩了不少的坑,废话不多说
安装node和npm
- 更新系统
首先,我们需要更新系统,以确保我们使用的是最新的软件包和依赖项。在终端中运行以下命令:
sudo apt update
sudo apt upgrade
- 安装Node.js
在Debian 11中,可以使用以下命令安装Node.js:
sudo apt install nodejs
- 安装npm
npm是Node.js的包管理器,可以使用以下命令安装:
sudo apt install npm
- 验证安装
安装完成后,可以使用以下命令验证Node.js和npm是否已正确安装:
node -v
npm -v
如果输出了版本号,则表示已成功安装。
运行
使用官方推荐的electron-forge来运行应用npm run start
"scripts": {
"start": "electron-forge start"
}
报错:[FATAL:electron_main_delegate.cc(294)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180
,目前还是未解决,在mac系统上是可以开发并运行的,所以先不运行了,能打包为deb文件就行
打包
使用官方推荐的electron-forge来打包应用npm run make
"scripts": {
"make": "electron-forge make"
}
- 报错1:
An unhandled rejection has occurred inside Forge:Error:Connot make for rpm,thefollowing extwnal binaries need to be installed:rpmbuild
这个错误是因为你缺少rpmbuild二进制文件,它是用于构建RPM软件包的工具。为了解决这个问题,需要安装rpmbuild工具。在Debian 11中,可以使用以下命令安装rpmbuild:
sudo apt install rpm
安装完成后,再次运行electron-forge make命令即可。
- 报错2:
An unhandled rejection has occurred inside Forge: Error: spawn zip ENOENT
这个错误是因为你的系统缺少zip命令,它是用于压缩文件的工具。为了解决这个问题,你需要安装zip工具。在Debian 11中,可以使用以下命令安装zip:
sudo apt install zip
安装完成后,再次运行electron-forge make命令即可。
- 报错3:
An unhandled rejection has occurred inside Forge: Error:No Description or ProductDescription provided.Please set editer a description in the app's package.json or provide it in the this.options.
这个是因为package.json
中缺少description
这个key,加上就好了 - 报错4:
error:License field must be present in package
这个是因为package.json
中缺少license
这个key,加上就好了