简体   繁体   English

Electron Forge 卡在松鼠上

[英]Electron Forge stuck on squirrel

I've been trying to package an electron app but it never goes past this stage:我一直在尝试 package 和 electron 应用程序,但它从未超过这个阶段:

在此处输入图像描述

I've tried 3 times and every time it takes hours but doesn't finish packaging for squirrel.我已经尝试了 3 次,每次都需要几个小时,但没有完成松鼠的包装。

package.json: 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": {}
        }
      ]
    }
  }
}

An application file appears in my out > win32-x64 folder but it's not an .exe file.我的out > win32-x64文件夹中出现了一个application文件,但它不是.exe文件。

I also have a random out > make > squirrel.windows > x64 folder that doesn't have anything in it.我还有一个随机out > make > squirrel.windows > x64文件夹,里面没有任何东西。

The process takes forever because you're packaging your whole app, node_modules included.这个过程需要很长时间,因为您正在打包整个应用程序,包括node_modules

A quick solution is to add the parameter "asar": true to you packagerConfig 1 .一个快速的解决方案是将参数"asar": true添加到您的packagerConfig 1中。 But unless you want to package the non-compiled files, you probably only want to keep the build folder.但除非你想 package 非编译文件,你可能只想保留build文件夹。

You already configured your scripts so a build is run before the make.您已经配置了脚本,因此在 make 之前运行构建。 Now since Electron Forge doesn't give the option to override dir 2 , you will have to use the ignore option to exclude the files and folders you don't want to have in the packaged app 3 .现在,由于 Electron Forge 没有提供覆盖dir 2的选项,因此您必须使用ignore选项来排除打包应用程序3中不想包含的文件和文件夹。

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

1. For the record, I found mentions of this here , here and here . 1. 作为记录,我在此处此处此处找到了有关此内容的提及。
2. As stated in the documentation → "Please note that you can not override the dir , arch , platform , out or electronVersion options as they are set by Electron Forge internally" 2. 如文档所述 → “请注意,您不能覆盖dirarchplatformoutelectronVersion选项,因为它们是由 Electron Forge 内部设置的”
3. See another example with this answer . 3. 看这个答案的另一个例子。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM