anol
anol

Reputation: 9115

Basic debugging of Electron apps

I'm using Electron to build a native application, based on existing code (developed with Electron v0.26.1). I'd like to use features available on more recent versions of Electron, so I changed the version number in package.json to v0.36.9 (the most recent one so far) and reinstalled its dependencies.

Now, I fully expected the applicaton to break when running npm start, and indeed it does, but I didn't expect the error message to be so uninformative:

Error opening app
The app provided is not a valid Electron app, please read the docs on how to write one:
https://github.com/atom/electron/tree/v0.36.9/docs

Error: Cannot find module '/home/user/electron/myapp/build'

I'd appreciate if it would say why it is no longer a valid Electron app, give any sort of stack trace, or file causing the issue.

Running npm start did create a build directory like before, which contains several files, just like before the upgrade. From the way it's worded, I cannot know if the Cannot find module message is the cause of the error, or the consequence. And if it is the cause, I have no idea of who or what is requiring such module, since before the upgrade this had never happened.

I tried "standard" debugging techniques, like running npm start --debug (the flag exists, but is not useful in this situation), npm rebuild, reading the Electron FAQ, looking for any *.log files (none to be found), and looking for occurrences of require('build') or something similar (no such occurrences). Nothing helped.

How can I get any information at all about why this is failing? Every programming language/build system I know of would at least output the source file where the error occurred, and possibly more information.

Upvotes: 1

Views: 1465

Answers (2)

anol
anol

Reputation: 9115

Well, after bisecting changes here and there, and following Vadim Macagon's advice to look further into package.json, I found out that the following change was responsible for the complete failure:

  • Changing "fs-jetpack": "^0.6.4" to "fs-jetpack": "^0.7.1"

Now, unfortunately I still have absolutely no idea about why that happened, or how I could have possibly found it out other than blindingly changing settings here and there.

This is not the answer to my question (I'd still like helpful information about how to debug Electron apps to avoid similar problems in the future), but it does allow me to keep working. That is, if I decide to keep using Electron, which I'm no longer sure it's a good idea.

Edit: There is at least one related issue on Github, but it has been closed and the issue has not been resolved.

Upvotes: 0

Vadim Macagon
Vadim Macagon

Reputation: 14847

In your app's package.json there probably something like:

"scripts": {
  "start": "electron /home/user/electron/myapp/build"
}

That's the command that will be executed when you run npm start, so fix the path in there to point to the .js file that contains your app entry point.

Upvotes: 1

Related Questions