-
-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
4.0.1 Error thrown in built Electron app #365
Comments
@LuanRT We integrated this library in https://github.com/th-ch/youtube-music Tests ran fine in dev mode, and it built fine, so the changes were merged Now upon building the app, I suddenly encounter this error :S This is kinda high priority, would love a quick solution thanks ♥ |
If you are using a bundler like webpack, you can write your code with ES6 imports and use the web version, as long as you are only using YouTube.js in the renderer (the node version of YouTube.js needs linkedom as a DOM polyfill, which is not needed in web browsers or the Electron renderer process). That's what we do for FreeTube, also comes with the addional benefit of a smaller app size. |
We are not using a bundler, and are using YouTube.js from the main process This definitely needs fixing anyway |
Seems like we look for performance in different areas. https://www.electronjs.org/docs/latest/tutorial/performance#7-bundle-your-code |
Thanks for the tip, but it has nothing to do with the issue here (or loading from renderer vs main) 😅 |
This is interesting. I wonder what's happening to the I'll set up a small Electron app to see if I can reproduce this. Note that I have no experience with Electron apps at all, so if anyone is able to help by doing some debugging too I'd appreciate. Also, as absidue said, you can try other entry points the library exposes; |
I think it's because the app is inside a more info in https://www.electronjs.org/docs/latest/tutorial/asar-archives
I can't really since we are loading it from Node.js and not the web (Electron main process vs renderer process) |
@LuanRT Ok sorry but I was completely wrong, it reads the package.json file correctly, but it's missing fields somehow...
and then YouTube.js/src/platform/node.ts Lines 102 to 107 in 1c72a41
Accesses |
This is extremely weird, I don't know what to think... what could ever cause the package.json to get so short like that? 😣 EDIT: I manually unpacked the asar, and it seems the this whole problem could be fixed by changing: runtime: 'node',
info: {
version: package_json.version,
- bugs_url: package_json.bugs.url,
+ bugs_url: package_json.bugs?.url,
- repo_url: package_json.homepage.split('#')[0]
+ repo_url: package_json.homepage?.split('#')[0]
}, (I have actually tested it, just adding a simple ? fixes everything) Sorry for spamming a bit, but atleast there is a one line fix 😝 |
I've opened a simple PR which fixes this issue |
That only fixes the crash, it doesn't actually solve the fundemental issue of the properties not being there. |
@Araxeus Anywho, it's still weird how the bug report URL is missing in |
Good enough for me 😅
I have truly no idea what's trimming the
It seems to be there, you can see the full package.json in my comment above
What if the const repo_url = package_json.homepage?.split('#')[0];
....
runtime: 'node',
info: {
version: package_json.version,
...(repo_url ? { repo_url, bugs_url: `${repo_url}/issues` } : {})
}, I'm assuming here that if const repo_url = package_json.homepage?.split('#')[0];
const bugs_url = package_json.bugs?.url;
....
runtime: 'node',
info: {
version: package_json.version,
repo_url: repo_url || "https://github.com/LuanRT/YouTube.js",
bugs_url: bugs_url || repo_url ? `${repo_url}/issues` : "https://github.com/LuanRT/YouTube.js/issues"
}, |
Steps to reproduce
Build an Electron app using
require('youtubei.js');
It will work in dev mode, but once the app is built then it will fail to load
Failure Logs
Expected behavior
The app loads
Current behavior
The app fails to load
Version
Default
Anything else?
I isolated the origin of the problem to this line:
YouTube.js/src/platform/node.ts
Line 28 in 1c72a41
this seems to not resolve in a built asar (which electron does)
and then the following lines throw:
YouTube.js/src/platform/node.ts
Lines 102 to 107 in 1c72a41
Checklist
The text was updated successfully, but these errors were encountered: