-
Notifications
You must be signed in to change notification settings - Fork 321
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
Can't load module if in .asar #76
Comments
I like the |
Well it's kind of a critical bug. People want to use node-notifier in their apps, but when compiling it to an app, if it doesn't work, i'd say that's quite critical and needs to be urgently fixed. |
I've looked through the repo code, but I can't see any reason for it not to be working, which is a real annoyance as I hoped it would have been something obvious that could be fixed with a couple lines of code, but it doesn't seem that way. As for me, i'm still learning Node so it might be obvious to @mikaelbr, but, who knows. I hope this gets patched soon though. |
We can only hope so.. and yes.. I agree that is quite critical! |
I think this has something to do with the bundling of electron. I need to get familiar with how that works. But if I were to guess, it would be for that electron have issues with bundling *.app files. |
The problem is that Electron compiles the included app files into a bundled file called |
That is probably due to it using binaries as dependencies (the bundled |
Ah that might be so. I hope you'll be able to fix this soon 😞 |
For future reference (for my self as well). Probably related: https://github.com/atom/electron/blob/master/docs/tutorial/application-packaging.md#extra-unpacking-on-some-apis |
I've looked some into this, and you should now be able to pack into Example packing that worked fine for me: asar pack . node-notifier.asar --unpack "./vendor/**" Would be great if you could try this out in master and let me know how it goes. |
I'll have to try this out later, thanks! I'll be busy for the next 2 days, but I'll be sure to test asap. |
You can do it if you want. I'll do it if not. |
I'm trying to test, but asar is giving me some troubles. Will let you know soon how it turns out. |
Good to see that you are working on it! I'll keep my fingers crossed! |
Any news here guys? |
I haven't been able to get it to work as of yet, but I think this is due to a problem with electron-packager. I'm still yet to get it working 😞 |
It seems to work for me? By using the command: asar pack . node-notifier.asar --unpack "./vendor/**" This is to make an asar pack . some-package.asar --unpack "./node_modules/node-notifier/vendor/**" |
It works! I had to do some hacky work arounds to get my Electron wrapper to work with it, but packaging the app into the asar with the provided command does indeed fix this issue. I'll go ahead and add it to the README, then close this issue. |
I still didn't manage to make it work.. I'm a bit new to both project so bare with me :) I unpacked the node notifier but then what?! How do I use it? Here I created this minimal project that shows one notification on click. Could anyone show me how/what should I update in order to be able to package it using the electron-packager? |
First
Once you have the binaries, run:
(change the module directory if needed) Lastly, open the resources directory (changes depending on OS), delete the Run the electron binary and give it a go. @lipis |
@kurisubrooks It worked!! Thanks a lot to both of you guys :) 💃 👯 💃 |
No prob! Glad we got it working for you 😄 |
👯 |
Still having problems with this on Win7 balloon notifications. Is this fix (asar unpacking) only for the OSX and Win8 notifications? Anyone have any luck using this for balloons? Unfortunately I can't get debugging working in my main process so I can't even see if its throwing errors. |
I don't see why it wouldn't work for Balloon notifications. Have you tried the command exactly as we mentioned above/in the README? @sean6bucks |
Yeah, did it exactly as above and was able to get the app.asar file as well as app.asar.unpacked folder whcih is structured as so (Im only using Toaster and Notifu): resources/app.asar.unpacked/node_modules/node-notifier/vendor/ which contains notifu/
toaster/
I also did an asar list of the app.asar and it lists those files still in the asar as well, so I tried packing it without them and keeping the unpacked folder but that didn't work either. (Sorry, total fail on teh structure diagram, improving) |
What files are in |
updated, I have the Notifu exe's and toast exe & dll's in unpacked |
It should look something like this:
Does this not work for you? @sean6bucks |
yup, thats exactly what I have minus the terminal notifier folder since Im not using it |
Would it be possible to find some sort of logging module that outputs the console log to a file, so we can see what's going on? I can't help without some sort of error or warning... I need to see something as to why this might be happening... Sorry |
@kurisubrooks Now I have another problem and that's with the icon. Lets say that my icon is in the So my question is.. how could I pack by ignoring two folders now.. including the |
On production it tries to read the image from this path:
and obviously fail. I though about have the icons unpacked as well and then simply replace the
|
Firstly, Instead of using As for your question, i'm unsure of how we'd be able to do something like Let me know if either of these work for you @lipis |
We tried a lot of combinations of |
Darn that's disappointing. Maybe go make an issue on their repo asking for a feature request. That's what I currently do with my app. I have a folder that I have all the exports in, then just export that folder. |
electron/asar#45 Let's see |
The check in asar happens here: https://github.com/atom/asar/blob/master/src/asar.coffee#L39 It uses minimatch and globs to match, so you can test your patterns by doing something like: var minimatch = require('minimatch');
var pattern = '{./node_modules/node-notifier/vendor/**,./img/**}';
console.log(minimatch('./img/icon.png', pattern, { matchBase: true }));
console.log(minimatch('./node_modules/node-notifier/vendor/terminal-notifier.png', pattern, { matchBase: true })); |
Hey @kurisubrooks just an update on the Win7 Balloon problems I was having. Finally got around to get a debug of the code and was receiving the error "Error: ENOENT, node_modules/node-notifier/vendor/notifu/notifu not found in ..MyApp/resources/app.asar" So I took a look in the balloon.js and notice it was looking for ".../notifu/notifu" which I assume is to handle the regular .exe and the 64.exe. For this we are only building a 32 bit version, so I changed the .js to notifu.exe and it fixed the problem. Not sure if this will help fix the problem if you need x32 & x64, but just wanted to let you guys know. Thanks! |
Thanks for the heads up! |
Yeah, I can check the underlying architecture type and explicitly set whether or not to use 32 or 64 bit version manually. |
In other news.. so it looks like electron will support notifications out of the box electron/electron@765cfb1 |
I've already been aware of Electron's notification APIs for some time, but it looks like they've finally got Windows integration somewhat working. Can't wait to see how they're going to integrate this, and what kind of features it will have. |
I'm using node-notifier only for Windows anyway.. so looking forward to that as well. No more asar hacks.. :) |
@kurisubrooks Hi, I met this problem too.And I pass the But, I still can't get notification, and the error is : Did I miss sth? |
@Darmody ENOENT means the directory doesn't exist, so it can't find the module. Double check you unpack the right folder. If you're sure, it doesn't look like you're getting the proper location, you can try something like this: const path = require('path');
// path to terminal-notifier:
var term_path = path.join('__dirname', 'node_modules', 'vendor', 'terminal-notifier.app', 'Contents', 'MacOS', 'terminal-notifier'); |
@kurisubrooks Thanks for your help, I think it is location problem too, I'll try the code you mentioned. |
Note, it should probably be var term_path = path.join(__dirname, 'node_modules', 'vendor', 'terminal-notifier.app', 'Contents', 'MacOS', 'terminal-notifier'); Not var term_path = path.join('__dirname', 'node_modules', 'vendor', 'terminal-notifier.app', 'Contents', 'MacOS', 'terminal-notifier'); (Notice in the second example |
When the module is compiled inside an Electron Binary File, the module will not load.
I've tried everything I can think of, but it refuses to load. Here's my current syntax that i'm using to require the module:
Everything else seems to work (using similar syntax), but node-notifier refuses to load.
This is the path's output. (Looks fine)
The text was updated successfully, but these errors were encountered: