Dead project when using electron-packager - help!


Hi, I’ve got an Electron-based project on Windows which is working well in my build directory via npm start. I’m now trying to create a distribution for the project and can’t make that work.

I’ve followed the web page to do manual distribution creation, and also tried using electron-packager. I end up with an executable that starts, launches two other processes but then seems to be waiting forever rather than completing initialisation and opening a window (as I would expect it to).

I’ve attached VSCode to the main process using --debug-brk=5858 and can see the process apparently starting, but I set several breakpoints in main.js (including at the top) and nothing gets hit. After initialisation, it says the executable isn’t in js code so it can’t display where we are, and a test connection of Visual Studio shows many threads but nothing enlightening happening (I don’t have the whole Electron package built in C++ though but am hoping to avoid having to go to that extent!)

I can’t think of how to even get started debugging this - any help would be greatly appreciated!



After much difficulty, I eventually found what was going wrong. It’s worth pointing out that the documentation for electron doesn’t make it very easy for newbies to find out what the command line switches are (I eventually looked at but there’s one really useful one for my case, --enable-logging (or set environmental variable ELECTRON_ENABLE_LOGGING) to get output that may tell you what’s happened.

I was using an npm module called ‘windows’ which requires node-path to be set and throws an exception if not. This exception occurred in a require(‘windows’) statement in the first window’s render process - but only if launched directly via the electron.exe command and not if launched via npm start. The exception was unhandled, obviously, and the two processes ended up waiting for events.

I really don’t like the idea that node-path needed to be set so I’ve worked around the need for that module and now I can start the program after packaging, as expected.