Hey,all
I followed the two package.json structure in the document, but when I ran npm run build, it reported an error that Application entry file couldn't be found in package.Seems like a wrong configuration

the package.json in the root of the project is:
...
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"postinstall": "install-app-deps",
"clean": "rimraf dist",
"build": "build"
},
"build": {
"app-bundle-id": "com.smartstudy.toefl",
"app-category-type": "public.app-category.education"
},
...
and the structure of app directory is:

the package.json in app directory is:
{
"name": "toefl",
"version": "0.0.1",
"description": "this is toefl-pc",
"main": "./index.js",
"private": true,
"author": "caibirdme",
"license": "ISC",
"dependencies": {
"request": "^2.71.0",
"sequelize": "^3.21.0",
"sqlite3": "^3.1.3"
}
}
version:
node 5.10.0
npm 3.8.3
electron 0.37.5
electron-builder 3.13.1
Try setting "main" property in your root package.json to be "app/index.js"
@Vj3k0 Fix will be tomorrow, for now I suggest just set version to 3.11.0
@caibirdme Cannot reproduce. Test passed for me.
Notes:
1) "clean": "rimraf dist", Please do not — electron-builder does it for you, — simplify your package.json and reduce build time.
2) Don't specify main explicitly — if file named as index.js, you don't need to specify it at all.
@demetris-manikas Maybe do you have any idea?
@caibirdme is there an app.asar being built? If so could you provide the output of asar list app.asar?
@develar unfortunately I won't be able to do any tests before Monday.
@caibirdme can you also please explain what is the "electron" listing in your app folder?
@demetris-manikas I think it maybe a problem of asar...if I add "asar": false in package.json, everything will be ok. My project is divided into three parts,: front_end,back_end and electron.electron is the only directory which has access to electron-api and will export functions that will be used in back_end or front_end
@caibirdme can you also answer to my previous question as well?
You can use externalResources to set data which needs to be accessed outside of asar. Asar is not considered a folder so path is broken to resource which is packed in it.
Does that help?
@demetris-manikas Sorry for my late reply,I was busy completing my dissertation.There is a app.asar in the foo.app/Contents/Resource.and when I ran ../../../../../node_modules/.bin/asar app.asar there's nothing listed.That is to say the app.asar is empty.
@Vj3k0 I use app.getPath to get the appData directory of one user and put all file to that place and app.asar should only contain my code.
@caibirdme asar app.asar doesn't output anything anyway. Try running
../../../../../node_modules/.bin/asar list app.asar
@demetris-manikas list command return an error.
../../../../../node_modules/.bin/asar list app.asar
undefined:1
{"files":{"electron":{"files":{"copyDb.js":{"size":599,"offset":"0"},"storeLocal.js":{"size":7346,"offset":"599"}}},"index.js":{"size":3149,"offset":"7945"},"node_modules":{"files":{"ansi-regex":{"files":{"index.js":{"size":135,"offset":"11094"},"license":{"size":1119,"offset":"11229"},"package.json":{"size":2504,"offset":"12348"},"readme.md":{"size":593,"offset":"14852"}}},"ansi-styles":{"files":{"index.js":{"size":1254,"offset":"15445"},"license":{"size":1119,"offset":"16699"},"package.json":{"size":2438,"offset":"17818"},"readme.md":{"size":1448,"offset":"20256"}}},"asn1":{"files":{".npmignore":{"size":19,"offset":"21704"},".travis.yml":{"size":44,"offset":"21723"},"lib":{"files":{"ber":{"files":{"errors.js":{"size":239,"offset":"21767"},"index.js":{"size":469,"offset":"22006"},"reader.js":{"size":5589,"offset":"22475"},"types.js":{"size":638,"offset":"28064"},"writer.js":{"size":7587,"offset":"28702"}}},"index.js":{"size":320,"offset":"36289"}}},"LICENSE":{"size":1076,"offset":"36609"},"pack
SyntaxError: Unexpected end of input
at Object.parse (native)
at Object.module.exports.readArchiveHeaderSync (/Users/deenjun/TOEFL-PC/node_modules/asar/lib/disk.js:97:20)
at Object.module.exports.readFilesystemSync (/Users/deenjun/TOEFL-PC/node_modules/asar/lib/disk.js:105:21)
at Object.module.exports.listPackage (/Users/deenjun/TOEFL-PC/node_modules/asar/lib/asar.js:175:17)
at Command.<anonymous> (/Users/deenjun/TOEFL-PC/node_modules/asar/bin/asar:42:23)
at Command.listener (/Users/deenjun/TOEFL-PC/node_modules/commander/index.js:301:8)
at emitTwo (events.js:100:13)
at Command.emit (events.js:185:7)
at Command.parseArgs (/Users/deenjun/TOEFL-PC/node_modules/commander/index.js:615:12)
at Command.parse (/Users/deenjun/TOEFL-PC/node_modules/commander/index.js:458:21)
@caibirdme So it seems that electron-builder error message is misleading and should be fixed (I 'll create a PR soon).
Can you confirm that the problem still arises on the latest stable release of electron-builder (3.17.1)?
Can also you clarify the OS on which your build fails? The output shows building on darwin but in 366 you mention that the error occurs when building on win7-x64. Thanks
Still get that error.
https://ci.appveyor.com/project/gamestailer94/quest-editor/build/1.0.42#L336
https://travis-ci.org/gamestailer94/quest-editor/jobs/131848606#L545
and the asar file is empty, if I run asar list app.asar I get an new Line and thats all
@gamestailer94 I saw that you reverted to electron-builder 3.11.
What is the result of asar list app.asar now?
Still empty, was just somethink i tryed in hope that it will wor.
https://travis-ci.org/gamestailer94/quest-editor/jobs/131896362#L906
https://travis-ci.org/gamestailer94/quest-editor/jobs/131896363#L617
no windows build, because no find on win ....
@gamestailer94 Good. This is why the warning is there. To safeguard you from publishing a "successful" build. I 'll try to reproduce and I' ll get back to you.
@gamestailer94 Can you please try setting the packageName equal to name in app/package.json and try again? There is an open bug (#360) when defining different values for the two.
@develar I reproduced the problem on linux and solved it as described above. I would be happy to create a PR to solve #360 but I will need some guidance. It is not very clear to me when to use name and when productName during the build process.
@demetris-manikas We should use productName in all cases except publish (we provide special names for publisher) and specific Linux cases. In the code this.appName it is a productName.
If we have myapp.app as result, but product name is MyApp, it means that we don't pass product name to electron-packager correctly — see https://github.com/electron-userland/electron-builder/blob/master/src/platformPackager.ts#L126 Maybe we should pass productName as well here (we use my fork — https://github.com/develar/electron-packager).
Can Confirm if ProductName and name are indetical it works
@demetris-manikas I will do it. name is build will be prohibited. I don't want configuration hell. It is not what users want. Why it is was allowed before? My mistake — forgot to forbid.
It will be not warning, but error — just because it doesn't work in any case.
Duplicate #360
@demetris-manikas Thanks for investigation.
@develar gamestailer94's problem has to do with another thing. gamestailer94 used as productName a value like "[QS] blah blah" and after investigating it turned out that the directory name is used by asar as a RegExp to find the files to add in the asar ( if [] exists the RegEpx fails to list anything and thus the empty asar file.
The fix can be applied at electron-builder or electron-packager-tf or asar itself and consists in escaping the src dir for RegExp usage (escape-string-regexp package did the trick for me).
I will file a PR soon at asar. but for fast usage the electron-packager-tf or electron-builder would do.
After giving a thought the pattern as source is an asar's feature so I wont be fileing a PR there. Would you like me to file a PR at electron-packager-tf ?
@demetris-manikas Proper fix should be not escaping, but disable RegExp handling on asar side.
After giving a thought the pattern as source is an asar's feature so I wont be fileing a PR there.
It is a pitfall. We pass path as path, not pattern. And should be simple way to disable regex instead of trying to escape it.
@develar Point taken. I 'll PR at asar and see what happens.
PR created. https://github.com/electron/asar/pull/68
@develar I don't fight with anyone. I am just proposing a solution to a problem. Escaping the directory in electron-packager is for me the right solution. The problem is clear and the fix as well. You take it from here. :)
Awesome avatar :joy: @caibirdme
@fritx Thx for ur praise
Most helpful comment
Try setting "main" property in your root package.json to be "app/index.js"