我正在尝试使用普通模板(无框架)打包一个电子应用程序。当我运行:npm run package 或yarn run package 时。我收到错误:
PS C:\GitHub\electron-project\lambda> yarn run package --platform win32
yarn run v1.22.22
$ electron-forge package --platform win32
✔ Checking your system
› Determining targets...
❯ Packaging for x64 on win32
✔ Copying files
⠸ Preparing native dependencies
⠸ Finalizing package
◼ Running postPackage hook
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
我的 forge.config.js 看起来像这样:
const { FusesPlugin } = require('@electron-forge/plugin-fuses');
const { FuseV1Options, FuseVersion } = require('@electron/fuses');
module.exports = {
packagerConfig: {
asar: true,
},
rebuildConfig: {},
makers: [
{
name: '@electron-forge/maker-squirrel',
config: {},
},
{
name: '@electron-forge/maker-zip',
platforms: ['darwin'],
},
{
name: '@electron-forge/maker-deb',
config: {},
},
{
name: '@electron-forge/maker-rpm',
config: {},
},
],
plugins: [
{
name: '@electron-forge/plugin-auto-unpack-natives',
config: {},
},
// Fuses are used to enable/disable various Electron functionality
// at package time, before code signing the application
new FusesPlugin({
version: FuseVersion.V1,
[FuseV1Options.RunAsNode]: false,
[FuseV1Options.EnableCookieEncryption]: true,
[FuseV1Options.EnableNodeOptionsEnvironmentVariable]: false,
[FuseV1Options.EnableNodeCliInspectArguments]: false,
[FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true,
[FuseV1Options.OnlyLoadAppFromAsar]: true,
}),
],
};
我的 packgage.json 看起来像:
{
"name": "lambda",
"productName": "lambda",
"version": "alpha-1.0.0",
"main": "src/index.js",
"scripts": {
"start": "electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make",
"publish": "electron-forge publish",
"lint": "echo \"No linting configured\""
},
"devDependencies": {
"@electron-forge/cli": "^7.4.0",
"@electron-forge/maker-deb": "^7.4.0",
"@electron-forge/maker-rpm": "^7.4.0",
"@electron-forge/maker-squirrel": "^7.4.0",
"@electron-forge/maker-zip": "^7.4.0",
"@electron-forge/plugin-auto-unpack-natives": "^7.4.0",
"@electron-forge/plugin-fuses": "^7.4.0",
"@electron/fuses": "^1.8.0",
"electron": "12.2.3",
"tailwindcss": "^3.4.3"
},
"keywords": [],
"author": "skyrxzz",
"description": "something but not empty",
"license": "MIT",
"dependencies": {
"electron-squirrel-startup": "^1.0.1",
"gkm": "^0.2.0",
"robotjs": "^0.6.0"
}
}
在节点 v16.14.0 上运行
我尝试打包一个电子应用程序,期待一个 win32 的包,但我收到了一个错误,没有告诉我任何有关问题的信息。
检查这里
我通过清除缓存解决了很多烦人的错误和错误。