Start electron with main.js in path differ of root dir


hi guys

I need to start my app /root/somepath/electron.js but an error occurs.
my folder structure is something like that:

– app1
----- electron.js
— app2
---- electron.js
– common
----- assets
– package.json

my project include various app thats use the same package.json, so, the “main” key of the package.json had to set a default filename like “electron.js” but in differ locations because the apps use differ electron.js files

my package.json should be like this:

“name”: “myapp”,
“version”: “1.0.0”,
“main”: “electron.ts”,
“scripts”: {
“app1”: "electron . ",
“app2”: "electron . ",
“devDependencies”: {
“electron”: “^1.7.8”,
“eslint”: “^4.7.2”,
“typescript”: “^2.5.3”

what I think in first place its include the location in scripts to indicate the main file dir, something like this script "electron . ./app1/electron.js"
but I didnt find anything about it on electron docs to do this

any ideas?


What you’ve posted for your package.json file says "main": "electron.ts", not electron.js.


whatever… the “.ts” its juts because I copy from my package.json, the real problem its change the location of main file on scripts section of my package.json rather than right on the main key


I think that you should get Electron working for a single app before you try to bundle multiple apps into one. If your package.json says that the file is supposed to be named electron.ts, Electron is going to look for a file of that name.