How to set root directory for electron app?



I’m just starting with electron and already it’s driving me nuts.

It seems that if I set up the application’s file structure in any other way that what’s presented in the “Writing Your First Electron App” tutorial, then I get weird errors trying to load the index file. (In the debugger->network it says it’s “blocked”, and it’s looking for it in some very odd directory deep in the node_modules/electron file structure).

The file structure suggested in the “First Electron App” tutorial is as follows:

├── package.json
├── main.js
└── index.html

And if I run “node_modules/electron/dist/electron .”, that works as expected.

However, if I try something “clever” such as:

├── package.json
├── /electron
└── /built-app

And then run either

cd built-app
…/node_modules/electron/dist/electron ./main.js
node_modules/electron/dist/electron ./built-app/main.js

Then everything screws up. The win.loadFile() line doesn’t work, and looking at the debugger->network it’s looking in some bizarre place for the index file.

Anyone got any clue what’s going on here?


It seems the “root directory” for my application defaults to “whatever folder holds the electron binary” … but why on earth would it do that? And how do I change it?