Version:
19.49.0
Target:
mac
I'm using create-react-app
and also followed below blog post.
https://medium.com/@kitze/%EF%B8%8F-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)
:
I 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:
Workaround: please add "extends": null to build.
I'm getting the exactly same error that @thinkholic mentioned, but on Windows.
The workaround didn't work.
I didn't checked with the workaround suggested by @andymorris yet. Hoping to try tonight.
Well... have you created this file?
@develar
created this file?
which?
https://medium.com/@kitze/%EF%B8%8F-from-react-to-an-electron-app-ready-for-production-a0468ecb1da3
Add this electron.js file to the “public” folder.
We’re adding it in the “public” folder instead of “src” so it can get copied to the “build” folder as it is. This is needed for the production version, and it’s explained later.
@develar yes I did.
and I'll update the issue later tonight after trying the workaround you have mentioned in #2030
Thanks!.
Tried with "extends": null
. still the same.
@develar
Changed --em.main
path to public/electron.js
in package.json
and then build was successful.
Now getting another error when I running installed app on my mac, but build error has fixed.
P.S.
Managed to fix issues and prepare a clean dev. environment. So closing the issue.
https://github.com/kodeflex/electron-cra
I have tried adding "extends: null
and also already had --em.main
path to public/electron.js
in package.json
and my build still fails. Any other ideas, I could try?
try script:
build -c.extraMetadata.main=
Somehow, setting files
work
"build": {
"files": [
"dist/**/*",
"package.json"
],
}
@patarapolw Thanks a lot. "build/**"
not work for me, but "build/**/*"
works like a charm
Don't forget point out main in package.json
"main": "./build/main/index.js",
Adding path to my electron-starter file in the "file" section worked for me.
https://github.com/electron-userland/electron-builder/issues/2955
"build": {
"appId": "com.example.electron-cra",
"files": [
"./build/**/*",
"./public/electron-starter.js"
],
"directories": {
"buildResources": "assets"
}
},
Simply adding "react-scripts" to the base project will cause this error.
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.
same problem, "preelectron-pack": "npm run build",
fixed the issue.
Somehow, setting
files
work"build": { "files": [ "dist/**/*", "package.json" ], }
@patarapolw It work for we , thanks
I'm getting this error cos I didnt build my cra first.
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
It seems depend on what the main
field is set in package.json
.
FYI,remove the "react-scripts": "^3.4.0" from dependencies works for me
Simply adding "react-scripts" to the base project will cause this error.
FYI,remove the "react-scripts": "^3.4.0" from dependencies works for me
Simply adding "react-scripts" to the base project will cause this error.
That's helpful for me too, thanks!
This seems very silly but I just realized running react-scripts was clearing the entire build folder which is where i set the compiled main script to output as well. simply swapping the build order and running them synchronously fixed my issue.
agregar en el pakage.json
"files": [
"build//",
"node_modules//",
"./public/electron.js"
],
Removing react-scripts
from my package.json deps fixed it for me. No idea why.
I don't understand why it just assumes the entry file is build/electron.js
, and there is no way to change that. I guess I just have to restructure my entire project, when they could have just given you the option to change the entry file.
It wouldn't be as big of a deal if I knew this was going to work, but as of now, this is the third packager I've tried, so the odds aren't looking good.
Like some people pointed out, react-scripts
causes the issue. And according to the documentation, this seems to be expected behavior
_extends_ String - The name of a built-in configuration preset or path to config file (relative to project dir). Currently, only react-cra is supported.
If react-scripts in the app dependencies, react-cra will be set automatically. Set to null to disable automatic detection.
It seems to sneak a react-scripts build
into the electron-builder
command. 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 exist
error.
Like the documentation says, disabling _extends_ in the built settings helped for me
package.json
{
...
"build": {
"extends": null,
...
}
}
Most helpful comment
Somehow, setting
files
work