Electron Forge 卡在松鼠身上

问题描述 投票:0回答:1

我一直在尝试打包一个电子应用程序,但它从未超越这个阶段:

enter image description here

我已经尝试了3次,每次都需要几个小时,但没有完成松鼠的包装。

package.json:

{
  "name": "NAME",
  "version": "0.1.0",
  "private": false,
  "author": "AUTHOR",
  "description": "DESCRIPTION.",
  "dependencies": {
    "@emotion/react": "^11.10.0",
    "@emotion/styled": "^11.10.0",
    "@fortawesome/fontawesome-svg-core": "^6.1.2",
    "@fortawesome/free-brands-svg-icons": "^6.1.2",
    "@fortawesome/free-solid-svg-icons": "^6.1.2",
    "@fortawesome/react-fontawesome": "^0.2.0",
    "@material-ui/core": "^4.12.4",
    "@mui/material": "^5.9.2",
    "@testing-library/jest-dom": "^5.16.4",
    "@testing-library/react": "^13.3.0",
    "@testing-library/user-event": "^13.5.0",
    "bootstrap": "^5.2.0",
    "cross-env": "^7.0.3",
    "electron": "^19.0.10",
    "electron-compile": "^6.4.4",
    "electron-forge": "^5.2.4",
    "electron-is-dev": "^2.0.0",
    "react": "^18.2.0",
    "react-bootstrap": "^2.4.0",
    "react-dom": "^18.2.0",
    "react-dropdown": "^1.10.0",
    "react-modal": "^3.15.1",
    "react-scripts": "5.0.1",
    "reactjs-popup": "^2.0.5",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "dev": "concurrently -k \"cross-env BROWSER=none npm start\" \"npm:electron\"",
    "electron": "wait-on tcp:3000 && electron .",
    "package": "react-scripts build && electron-forge package",
    "make-mac": "react-scripts build && electron-forge make --platform darwin",
    "make-linux": "react-scripts build && electron-forge make --platform linux",
    "make": "react-scripts build && electron-forge make"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "concurrently": "^7.3.0",
    "electron-prebuilt-compile": "8.2.0",
    "wait-on": "^6.0.1"
  },
  "main": "public/electron.js",
  "homepage": "./",
  "config": {
    "forge": {
      "packagerConfig": {},
      "makers": [
        {
          "name": "@electron-forge/maker-squirrel",
          "config": {
            "name": "stock_trading_app"
          }
        },
        {
          "name": "@electron-forge/maker-zip",
          "platforms": [
            "darwin",
            "linux",
            "win32"
          ]
        },
        {
          "name": "@electron-forge/maker-deb",
          "config": {}
        },
        {
          "name": "@electron-forge/maker-rpm",
          "config": {}
        }
      ]
    }
  }
}

我的

application
文件夹中出现了
out > win32-x64
文件,但它不是
.exe
文件。

我还有一个随机的

out > make > squirrel.windows > x64
文件夹,里面没有任何东西。

javascript reactjs npm electron electron-forge
1个回答
4
投票

这个过程需要很长时间,因为您正在打包整个应用程序,包括

node_modules

一个快速的解决方案是向您添加参数

"asar": true
packagerConfig
1。但除非你想打包未编译的文件,否则你可能只想保留
build
文件夹。

您已经将脚本配置为在

build
之前运行
make
。现在,由于 Electron Forge 没有提供覆盖
dir
2 的选项,因此您必须使用
ignore
选项来排除您不想在打包中包含的文件和文件夹应用程序3.

packagerConfig: {
    ignore: [
        "^\\/public$",
        "^\\/src$",
        "^\\/node_modules$",
        "^\\/[.].+",
        // [...]
    ]
},

1。作为记录,我在这里这里这里找到了提及。
2. 如文档中所述→“您不能覆盖

dir
arch
platform
out
electronVersion
选项,因为它们是由 Electron Forge 内部设置的。”
3. 请参阅另一个示例,此答案

© www.soinside.com 2019 - 2024. All rights reserved.