electron-builder: Error: Application entry file "build/electron.js" in the "/dist/mac//Contents/Resources/app.asar" does not exist.
-
Version:
19.49.0 -
Target: mac
I’m using create-react-app and also followed below blog post.
https://medium.com/@kitze/️-from-react-to-an-electron-app-ready-for-production-a0468ecb1da3
Error: Application entry file "build/electron.js" in the "/Users/jarvis/Dev/sandbox/elec-app/dist/mac/elec-app.app/Contents/Resources/app.asar" does not exist. Seems like a wrong configuration.
at error (/Users/jarvis/Dev/sandbox/elec-app/node_modules/electron-builder-lib/src/asar/asarFileChecker.ts:7:12)
at /Users/jarvis/Dev/sandbox/elec-app/node_modules/electron-builder-lib/src/asar/asarFileChecker.ts:33:11
at next (native)
at /Users/jarvis/Dev/sandbox/elec-app/node_modules/graceful-fs/polyfills.js:287:18
at FSReqWrap.oncomplete (fs.js:123:15)
:
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 35
- Comments: 39 (3 by maintainers)
Commits related to this issue
- build: fix build config and let npm script uses yarn by default references: - https://github.com/electron-userland/electron-builder/issues/2404 — committed to alibaba/lightproxy by ahonn 4 years ago
- Fix missing entry point file error. See https://github.com/electron-userland/electron-builder/issues/2404#issuecomment-1243608565 — committed to friendsofagape/autographa by joelthe1 2 years ago
- v2.2.0 (#690) * Xelah USFM editor integration * Fix missing entry point file error. See https://github.com/electron-userland/electron-builder/issues/2404#issuecomment-1243608565 * Fixing the... — committed to friendsofagape/autographa by joelthe1 2 years ago
- feat(ch01): fix the build option ref: - https://github.com/electron-userland/electron-builder/issues/2404#issuecomment-469300902 — committed to llama90/electron-projects-typescript by llama90 a year ago
Somehow, setting
filesworkI was also getting this error (though I’m trying to build on Windows with 19.52.1) and just wanted to note that the workaround described in #2030 worked for me:
Like some people pointed out,
react-scriptscauses the issue. And according to the documentation, this seems to be expected behaviorIt seems to sneak a
react-scripts buildinto theelectron-buildercommand. Interestingly enough, the react-scripts fails for me if run separately, but not when wrapped into the original command. Anyways, you end up with the intransparent"build/electron.js" file does not existerror.Like the documentation says, disabling extends in the built settings helped for me
package.json
Adding path to my electron-starter file in the “file” section worked for me. https://github.com/electron-userland/electron-builder/issues/2955
Simply adding “react-scripts” to the base project will cause this error.
It seems depend on what the
mainfield is set inpackage.json.If you are like me and neither of the above solutions work, simply remove the “files” section completely and it’ll start working magically!
FYI,remove the “react-scripts”: “^3.4.0” from dependencies works for me
https://www.hi917.com/detail/325.html
解决了我的问题
Tried everything… for me solution was just to rename the file itself public/main.js to public/electron.js and as well as updating “main”: “public/electron.js” in package.json
after this update (which means that it wasn’t complaining anymore about not finding electron.js file 🎉) I moved on to another error for the wrong code sign 😩…
Update: Mac gave me issue with Codesign because I have two emails possible solution would be in #2125 But just tested on my Linux and everything worked like a charm after changing the file name to electron.js as I mentioned above.
Cheering you up: I know you are struggling a lot with this, but trust me Keep Gooing It feels so good once you see your built app 😍 and call yourself Genius 😅 Happy coding
@ericblade yeah electron-builder is really powerful but the documentation is super messy. The problem I just faced is that by default,
extraMetadataseems to setmainto"main.js". Like this:… and it overrides the value that is set in your
package.json, which is really unexpected.having similar issue here, but it’s calling the entrypoint “index.js”, which does not correspond to anything in my project, at all. The package.json points to main as “build/main.js”. Inside the asar file, are a small collection of node modules I’ve never heard of, and absolutely nothing else. It’s like builder is just completely ignoring everything inside the configuration it claims it’s loading.
I’m so very confused.
And the documentation is incomprehensible.
try script: build -c.extraMetadata.main=<path/to/electron.js>
Well… have you created this file?
Not sure this will help much, but (in my case) I found that my preelectron-pack was not executing correctly, thus not creating the build folder.
I followed a derived instruction from the mentioned by the OP and found that the build folder wasn’t there.
As I use npm, I changed the line
"preelectron-pack": "npm run-script build",and it solved the issue for me.@patarapolw Thanks a lot.
"build/**"not work for me, but"build/**/*"works like a charmDon’t forget point out main in package.json
"main": "./build/main/index.js",For me it solved by : pass in the entry file path externally, using files param then over write the “main” with that file name using extraMetadata param
as follows:
I’m getting the exactly same error that @thinkholic mentioned, but on Windows.
The workaround didn’t work.
This problem drove me mad for a while (my server is built into the non default path of
build/server/electron.jsinstead of justbuild/electron.js). for some reason setting “main” tobuild/server/electron.jswouldn’t fix this issue, the only thing that worked was as per @mifi additional info.agregar en el pakage.json “files”: [ “build//*", "node_modules//*”, “./public/electron.js” ],
@patarapolw It work for we , thanks
I’m getting this error cos I didnt build my cra first.