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 common.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.
更换main
中package.json
与.webpack /主
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 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.