最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - Electron-forge npm run make "Error: The main entry point to your app was not found." - Stack Over

matteradmin1PV0评论

My electron app is in its final stage where I try to use electron-forge to make it into an executable. Running it through npm run start gave no problem, however when running npm run make new errors came up. 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.

  "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 mon.js where the error arose. 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. Hopefully this error is not due to the out folder not generating the content.

My electron app is in its final stage where I try to use electron-forge to make it into an executable. Running it through npm run start gave no problem, however when running npm run make new errors came up. 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.

  "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 mon.js where the error arose. 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. Hopefully this error is not due to the out folder not generating the content.

Share Improve this question asked Sep 7, 2021 at 20:55 TuftedDuckDebuggerTuftedDuckDebugger 1511 silver badge10 bronze badges
Add a ment  | 

7 Answers 7

Reset to default 4

For people who are struggling to get Electron to recognize the index.js within "./out/main/", I literally just renamed the out folder to dist and adjusted the the package.json file accordingly. Then it suddenly worked. Very weird.

I had a similar problem when main.js was not contained in a subdirectory below the directory containing package.json. The solution that worked for me was to create a symbolic link to main.js in a subdirectory. This seems to be a requirement of electron-forge.

replace the main in package.json with .webpack/main

To make it work for me, I had to remove the ./ from the start of my main declaration. So for you it would read "main": "src/main.js"

This is weird because it reports the file path correctly in the error message

I had the same problem. I solved it changing

"main": "./out/main/index.js"

to

"main": "./dist/main/index.js"

It was fixed because I pointed the path where my piled program was.

What worked for me was to add .js at the end of main inside the package.json file

like so

{
  ...
  "main": "main.js",
  ...
}

You will need to rename your out folder to dist As mentioned in the documentation, check the warning

Warning

Electron Forge's default output directory is out and forbids to override, which conflicts with electron-vite. So we can set outDir to dist.

Additionally, you will need to update your scripts in package.json and your entry

"main": "./dist/main/index.js",
"scripts": {
  "start": "electron-vite preview --outDir=dist",
  "dev": "electron-vite dev --outDir=dist",
  "package": "electron-vite build --outDir=dist && electron-forge package",
  "make ": "electron-vite build --outDir=dist && electron-forge make"
},

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far