Basic debugging of Electron apps - node.js

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.

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.

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.

Related

Convert existing Angular project to Universal, encounter 'referenceerror: navigator is not defined'

I recently faced the task of converting a fairly mature angular project to SSR because I had overestimated the search power of SEO in angular projects. I'm not familiar with node, my angular project is on an apache server and uses php(slim) as the backend api, however, when I started trying to use "most of the tutorials", i.e., the first step, introducing nguniversal/express-engine into the project, it went well, npm did not report any errors.
Then I tried to run npm run build:ssr and it also worked fine. The problem is that when I run npm run serve:ssr, it ends up throwing a "ReferenceError: navigator is not defined" error...
Earlier, I built a completely clean angular project for testing, from build:ssr to run serve:ssr. Even I specified node xxxx/xxxx/main.js directly, no problem, which is obvious, because the angular project for testing is absolutely clean.
However, this does not work on my current "existing angular project". Yes, I fully understand that SSR doesn't allow for navigator or most so-called DOM manipulation, and although I'm not familiar with angular universal yet, I've previewed it and I know that's not possible, but here's the biggest problem :
In this existing angular project, there is no any navigator operations, not even a single line of code
In fact, main.js is also generated automatically, I can't stop it at all, I don't understand why there is "navigator" written in main.js?
I've checked many so-called solutions, including writing something in server.ts, but nothing helps, how can I continue? This is really quite desperate!
Big thank any help!

Node project failed to start application and cannot solve error

I'm having errors on my networked-aframe project. I can edit it on Glitch, but when press ‘Show’ it shows : failed to start application on ilearn-official.glitch.me This is most likely because your project has a code error.Check your project logs, fix the error and try again.
As a newbie, I’m having a hard time finding and solving the error. Can anyone help? Here’s my glich code:https://glitch.com/edit/#!/ilearn-official
Taking a look at your Glitch app's package.json file, it looks like you're using Node 6.9.x which is wildly out of date and probably at odds with some of the Node your app has in it. If you update the engine to Node 14.x, that should help with that particular error.

How can I solve a crash in an Adonis app starting?

this is my first question ever. I'm trying to run an Adonis.js app by entering adonis serve --dev at the terminal. The messages are always the same in this succession:
SERVER STARTED
Watching files for changes...
Fatal error in , line 0
Check failed: U_SUCCESS(status).
FailureMessage Object: 000000D7655ECBA0Application crashed, make sure to kill all related running process, fix the issue and re-run the app
The only thing that changes is the FailureMessageObject. My Node version is 12.0, npm 6.9.
I can't say anything seriously working on your situation cause you gave me no detailed data but I know that surely you are doing something wrong.
It could be better if you at least mentioned the version of adonisjs you've been using.
Anyway, if you learned to run your server from a video from someone else's youtube channel, I strongly recommend you to read documentation and stop watching those videos.
And for adonisjs there are 2 different documentation:
adonisjs's Documentation, version 4.1 or less.
You can change the version on top left combo box.
adonisjs's preview Documentation, version 5.0.
Actually the documentation is not still completed at this time but the version is stable. yeah, that's the reason why I wrote preview.
And that's it, start recreating an adonisjs app from documentation guides.
I solved it. It was something with node or npm. I followed this steps enumerated in this post: How to completely remove node.js from Windows. Reinstalled node. Installed Adonis and it's CLI again and created an app and this time the app didn't crashed, and ran smoothly (after that I also created some migrations and they too worked well).

I'm afraid I've installed a scam npm package: how to analyse a Wasm?

I've installed and executed (with nodejs) a package from npm: https://www.npmjs.com/package/openssl.js
Somehow I didn't realize that it hasn't a good reputation (almost no activity/stars on twitter, github). Now I'm afraid that it is a scam. The worst case would be that is stealing/encrypting my data or something like that.
I've checked the processes, I/O and network in the activity monitor but nothing interesting.
But I would like to have more confidence that everything is okay.
Since it is a Wasm file I cannot just check the source code.
I've tried to decompile with this tool: https://github.com/WebAssembly/wabt but it gives me for all binaries in that project this error: error: #0x00000004: bad magic value.
Maybe because in the README of the openssl.js package they claim it is build with wasienv toolchain?
Another idea would be install a honeypot and run the same commands in the honeypot. But which honeypot is suitable for this?
// edit
I was able to run wasm2c on this file: src/raw-wasm/openssl.wasm.
But how can I ensure there was no network interactivity?
Here are the first lines of the output: https://pastebin.com/YYHecFAC

Is it possible to make Visual Studio call npm install when an updated package.json is downloaded from source control?

I know that when I manually update the package.json file, VS will run an npm install. However, if someone else updates it and checks it into source control, when I download it, npm install doesn't get called. I have to either save package.json (even if I don't make any changes), or call it myself from a command prompt. It will be really frustrating if we have to communicate to the entire team that they each need to perform some action after getting package.json, any time a change is made.
Is this just a missing feature in Visual Studio, or am I missing something that would allow it work as expected?
Our project is still an old Webforms project (Yeah I know. It's not by the dev team's choice.), so it doesn't have the Dependencies node in Solution Explorer. I realize this might be the problem, and it would possibly all work correctly if we were using an ASP.NET 5 MVC project. However, saving package.json does launch npm install, so the basic support still works. So, if that is the problem, I'd like confirmation on it.
I tried asking this on the VS forums also, and only got a response from a single MS CSG who obviously didn't understand what I was asking. I got tired of the frustration of trying to explain it to him, and dropped it. Since no one else responded, I'm assuming the answer is that it's not possible.
I've created a UserVoice suggestion for it, and suggest everyone that has votes avilable to upvote it.
I have noticed that it does call npm install when you open the solution file (and probably when opening just the project file, although I haven't tried that). That's a little better, but since I usually leave VS open and just hibernate my computer at the end of the day, I don't actually open the solution/project file that often.

Resources