npm run make 在电子锻造中不起作用

时间:2021-05-20 08:45:53

标签: electron electron-builder electron-packager electron-forge

我已经创建了电子应用程序并尝试使用电子伪造来构建目的。 请在下面找到我运行它以创建电子应用程序的命令:

   #npm i -g create-react-app
   #npm i -g @electron-forge/cli
   #npx create-electron-app my-ele-app

上面的最后一条命令创建了一个项目 my-ele-app。现在我也可以启动应用程序了。 #npm 开始。

package.json 文件内容为:

{
  "name": "my-ele-app",
  "productName": "my-ele-app",
  "version": "1.0.0",
  "description": "My Electron application description",
  "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\""
  },
  "keywords": [],
  "author": {
    "name": "rohit",
    "email": "rohit@xyz.com"
  },
  "license": "MIT",
  "config": {
    "forge": {
      "packagerConfig": {},
      "makers": [
        {
          "name": "@electron-forge/maker-squirrel",
          "config": {
            "name": "my_ele_app"
          }
        },
        {
          "name": "@electron-forge/maker-zip",
          "platforms": [
            "darwin"
          ]
        },
        {
          "name": "@electron-forge/maker-deb",
          "config": {}
        },
        {
          "name": "@electron-forge/maker-rpm",
          "config": {}
        }
      ]
    }
  },
  "dependencies": {
    "electron-squirrel-startup": "^1.0.0"
  },
  "devDependencies": {
    "@electron-forge/cli": "^6.0.0-beta.55",
    "@electron-forge/maker-deb": "^6.0.0-beta.55",
    "@electron-forge/maker-rpm": "^6.0.0-beta.55",
    "@electron-forge/maker-squirrel": "^6.0.0-beta.55",
    "@electron-forge/maker-zip": "^6.0.0-beta.55",
    "electron": "12.0.9"
  }
}

现在当我在命令下运行时,它抛出错误:

#npm run make

错误是:

> my-ele-app@1.0.0 make
> electron-forge make

√ Checking your system
√ Resolving Forge Config

An unhandled rejection has occurred inside Forge:
Error: Could not find module with name: @electron-forge/maker-squirrel. Make sure it's listed in the devDependencies of your package.json
    at _default (C:\Users\212807091\Desktop\Rohit\Office Note\RBAC\Electron_project\npx_electrong\my-ele-app\node_modules\@electron-forge\core\src\api\make.ts:125:15)
    at C:\Users\212807091\Desktop\Rohit\Office Note\RBAC\Electron_project\npx_electrong\my-ele-app\node_modules\@electron-forge\cli\src\electron-forge-make.ts:44:5

Electron Forge was terminated. Location:
{}

注意:我可以看到 node_modules 文件夹中有可用的模块: my-ele-app\node_modules@electron-forge\maker-squirrel

如果这里有人知道如何解决这个问题。请提供答案。谢谢!

2 个答案:

答案 0 :(得分:0)

按照“入门”说明操作后,我遇到了同样的错误。在我运行 npm install -g @electron-forge/cli@beta 之前,什么都没有解决 - 完成后我能够成功运行 electron-forge make。 同样运行 npm run make 与电子伪造 make 的作用相同,因为我似乎没有安装它。我注意到的另一件事是,如果我在 version 6.0.0-beta.55 处使用 maker-squirrel 运行 npm run make,则会出现此错误:找不到名称为 @electron-forge/maker-squirrel 的模块。但是,如果我将 maker-squirrel 重新安装为 npm install --save-dev @electron-forge/maker-squirrel@6.0.0-beta.33 并重新运行 npm run make,那么我会得到一个带有 exe 的 out 文件夹。

答案 1 :(得分:0)

您已经安装了所有必需的依赖项,因此只需运行此命令

npm run package

在此之后,会生成一个名为 out 的文件夹,其中将出现您的 .exe 文件