Reputation: 151
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.
Upvotes: 5
Views: 9302
Reputation: 586
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"
},
Upvotes: 0
Reputation: 1
What worked for me was to add .js
at the end of main
inside the package.json
file
like so
{
...
"main": "main.js",
...
}
Upvotes: 0
Reputation: 41
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.
Upvotes: 4
Reputation: 1
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 compiled program was.
Upvotes: 0
Reputation: 21
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.
Upvotes: 2
Reputation: 129
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
Upvotes: 0