Reputation: 42418
I have an electron app and I got this error when run electron-builder build
.
Error: Application entry file "main.js" in the "/project/dist/release/mac/demo.app/Contents/Resources/app.asar" does not exist. Seems like a wrong configuration.
This is package.json. I have set the main
to dist/electron.js
but I don't understand why it keep saying main.js
doesn't exist.
...
"main": "dist/electron.js",
"build": {
"productName": "demo",
"appId": "com.auspost.pos",
"files": [
"dist/",
"node_modules/**/*",
"package.json",
"dist/electron.js"
],
"directories": {
"output": "dist/release"
},
"dmg": {
"contents": [
{
"x": 130,
"y": 220
},
{
"x": 410,
"y": 220,
"type": "link",
"path": "/Applications"
}
]
},
"win": {
"target": [
"nsis",
"msi"
],
"icon": "./electron/assets/icons/win/app.ico"
},
"publish": {
"provider": "github"
}
},
...
"devDepencencies": {
"electron": "^5.0.2",
"electron-builder": "^20.41.0",
"electron-webpack": "^2.6.2",
}
Upvotes: 3
Views: 8337
Reputation: 868
If your main electron entry point file is called electron.js as you mentioned.
Then you 1st need to build your application in production:
ng build --configuration production
Now you should have your built code in your dist folder. (it can also be in the dist/YourApp folder and then you need to modify the path accordingly) In here you will have your electron.js file. You should verify that is it there.
Now in package.json you need to specify the path to electron.js file with the main parameter
In package.json:
"main": "dist/electron.js"
OR if you file is in dist/YourApp
"main": "dist/yourApp/electron.js"
Electron builder takes your built code and transforms it into an installer.
Upvotes: 0
Reputation: 2225
I encountered the error when selecting the production version of my entry file which was in a different folder than the source production file.
Here is the relevant config section that got my app to build:
"build": {
"files": [
"electron-settings.json",
"package.json"
],
"extraResources": [
{
"from": "../build/backend/min",
"to": "app",
"filter": [
"**/*"
]
},
{
"from": "desktop/node_modules",
"to": "node_modules"
}
],
"mac": {
"extraResources": [
{
"from": "build/osx",
"to": "app/build/osx"
}
]
}
}
Upvotes: 0
Reputation: 1840
I had a similar issue:
Application entry file "index.js" in the ".....\dist\win-unpacked\resources\app.asar" does not exist.
The fix for me was to add
main: "main.js"
in the package.json of the generated app, so .\app\package.json. Seems like without this electron-builder 21 (electron 6) is looking for a "index.js" file.
Upvotes: 1
Reputation: 42418
Finally figure out that because the project has electron-webpack
dependency which works as a base template for electron build configuration. There are some fields are defined there which get extended.
The fix for that is either remove electron-webpack
from your project dependencies or use electron-webpack
convention to manage your project.
Upvotes: 1