简体   繁体   English

Electron-forge npm run make“错误:找不到您的应用程序的主要入口点。”

[英]Electron-forge npm run make "Error: The main entry point to your app was not found."

My electron app is in its final stage where I try to use electron-forge to make it into an executable.我的电子应用程序处于最后阶段,我尝试使用 electron-forge 使其成为可执行文件。 Running it through npm run start gave no problem, however when running npm run make new errors came up.通过npm run start运行它没有问题,但是在运行npm run make时出现了新错误。 I fixed all until this absurd error came up.我修复了所有问题,直到出现这个荒谬的错误。

An unhandled rejection has occurred inside Forge: Error: The main entry point to your app was not found. Make sure "C:\Users\Admin\Documents\Programming\Lucrative Projects\studyplanner\src\main.js" exists and does not get ignored by your ignore option

What makes this absurd is that the file indeed exists...使这个荒谬的是,该文件确实存在...... 在此处输入图像描述

Furthermore nothing in the package.json would indicate that something is ignored.此外, package.json 中的任何内容都不会表明某些内容被忽略。

  "name": "studyplanner",
  "version": "1.0.0",
  "description": "My electron app",
  "main": "./src/main.js",
  "scripts": {
    "start": "electron-forge start",
    "dev": "webpack --watch && electron .",
    "build": "rimraf ./public && mkdir public && webpack --progress -p",
    "package": "electron-forge package",
    "make": "electron-forge make"
  },
  "license": "MIT",
  "devDependencies": {
    "@babel/core": "^7.15.5",
    "@babel/plugin-proposal-class-properties": "7.12.1",
    "@babel/preset-env": "^7.15.0",
    "@babel/preset-react": "^7.14.5",
    "@electron-forge/cli": "^6.0.0-beta.60",
    "@electron-forge/maker-deb": "^6.0.0-beta.60",
    "@electron-forge/maker-rpm": "^6.0.0-beta.60",
    "@electron-forge/maker-squirrel": "^6.0.0-beta.60",
    "@electron-forge/maker-zip": "^6.0.0-beta.60",
    "@electron-forge/plugin-webpack": "^6.0.0-beta.60",
    "@vercel/webpack-asset-relocator-loader": "^1.7.0",
    "babel-loader": "^8.2.2",
    "copy-webpack-plugin": "6.3.2",
    "css-loader": "3.6.0",
    "electron": "9.3.1",
    "extract-text-webpack-plugin": "3.0.2",
    "file-loader": "6.2.0",
    "html-webpack-plugin": "4.5.0",
    "node-loader": "^2.0.0",
    "postcss": "7.0.32",
    "postcss-cssnext": "3.1.0",
    "postcss-import": "12.0.1",
    "postcss-load-config": "2.1.0",
    "postcss-loader": "3.0.0",
    "postcss-nesting": "7.0.1",
    "rimraf": "3.0.2",
    "style-loader": "1.2.1",
    "url-loader": "4.1.0",
    "webpack": "4.43.0",
    "webpack-cli": "3.3.12"
  },
  "dependencies": {
    "@babel/cli": "^7.14.8",
    "@babel/node": "^7.14.9",
    "@babel/register": "^7.15.3",
    "axios": "^0.21.1",
    "babel-jest": "^27.1.0",
    "babel-preset-react": "^6.24.1",
    "classnames": "2.2.6",
    "dotenv": "8.2.0",
    "electron-squirrel-startup": "^1.0.0",
    "express": "4.17.1",
    "morgan": "^1.10.0",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "regenerator-runtime": "^0.13.9"
  },
  "config": {
    "forge": {
      "packagerConfig": {},
      "makers": [
        {
          "name": "@electron-forge/maker-squirrel",
          "config": {
            "name": "studyplanner"
          }
        },
        {
          "name": "@electron-forge/maker-zip",
          "platforms": [
            "darwin"
          ]
        },
        {
          "name": "@electron-forge/maker-deb",
          "config": {}
        },
        {
          "name": "@electron-forge/maker-rpm",
          "config": {}
        }
      ],
      "plugins": [
        [
          "@electron-forge/plugin-webpack",
          {
            "mainConfig": "./webpack.main.config.js",
            "renderer": {
              "config": "./webpack.renderer.config.js",
              "entryPoints": [
                {
                  "html": "./src/index.html",
                  "js": "./src/renderer.js",
                  "name": "main"
                }
              ]
            }
          }
        ]
      ]
    }
  }
}

I looked in common.js where the error arose.我查看了出现错误的 common.js。 I tried replacing line 155's if (!(await fs.pathExists(mainScript))) with if (!(await fs.pathExists(originalMainScript))) but that only made an out without any files in resources/app , only some in .webpack .我尝试用 if (!(await fs.pathExists(originalMainScript))) 替换第 155 行的if (!(await fs.pathExists(mainScript))) if (!(await fs.pathExists(originalMainScript)))但这只是在resources/app out没有任何文件,只有一些在.webpack Hopefully this error is not due to the out folder not generating the content.希望此错误不是由于 out 文件夹未生成内容。

更换mainpackage.json与.webpack /主

To make it work for me, I had to remove the ./ from the start of my main declaration.为了使它对我./ ,我必须从main声明的开头删除./ So for you it would read "main": "src/main.js"所以对你来说,它会读为"main": "src/main.js"

This is weird because it reports the file path correctly in the error message这很奇怪,因为它在错误消息中正确报告了文件路径

I had a similar problem when main.js was not contained in a subdirectory below the directory containing package.json.当 main.js 不包含在包含 package.json 的目录下的子目录中时,我遇到了类似的问题。 The solution that worked for me was to create a symbolic link to main.js in a subdirectory.对我有用的解决方案是在子目录中创建指向 main.js 的符号链接。 This seems to be a requirement of electron-forge.这似乎是电子锻造的要求。

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

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