node-notifier
node-notifier copied to clipboard
Does not show icon after being packed in asar
So as said , using electron-packager, it does not show the icon.
Using the --asar=true property in electron-packager, does not allow for the icon to show.
Have you seen this guide? https://github.com/mikaelbr/node-notifier#within-electron-packaging
So what is my webpack? I dont have one of those?
Ok. I'm sorry, but did you give this the proper time and actually read what section I referred to? Within Electron Packaging
Here's the text:
If packaging your Electron app as an asar, you will find node-notifier will fail to load.
Due to the way asar works, you cannot execute a binary from within an asar. As a simple solution, when packaging the app into an asar please make sure you --unpack the vendor/ folder of node-notifier, so the module still has access to the notification binaries.
You can do so with the following command:
asar pack . app.asar --unpack "./node_modules/node-notifier/vendor/**"
I'm not familiar with electron-packager (it's kind of out of the scope of this project), but it seems to me that the asar packaging (which AFAIK flattens the structure and creates some faux file system) isn't instructed to maintain the path for your icon, thus you referring to the icon in your code has the wrong path.
Yes I have, And Im telling you I dont have a webpack and I do not have asar installed to run commands since you dont need to in order to package an app. Also how would I even unpack it after it is already packed using the npm script I have created?
Also I have followed this 'guide', I installed asar globally, Packed the app. And still no icon.
electron-packager . BTCPlus --asar=true --icon=assets/icons/win/icon --out=release-builds --version-string.FileDescription=CE --version-string.ProductName="BTC+""
Thats my script, As said I have also tried the manual unpacking of the node modules as you have shared. Does not work. And with my current script I get a warn that asar does not use sub properties.
--asar.unpack="node_modules/node-notifier/vendor/**" - This works
However, The icon for the notification is still not appearing.
--asar.unpack="node_modules/node-notifier/vendor/**"
doesn`t work for me
I solved it like this(i used it in angular with electron project):
electron-packager . --overwrite --asar --platform=win32 --arch=x64 --extra-resource=dist/assets/img/some-icon.png
above command unpack icon to resources folder:

and we have absolute path to the icon
notifier.notify(
{
icon: path.join(__dirname, '../some-icon.png'),
}
);
and icon is show in notification
I stumbled upon this question and I found that what works for me is:
icon: path.join(__dirname, app.isPackaged ? '../app.asar.unpacked/res/icons/icon.png' : "/res/icons/icon.png")
(I'm using electron-builder, though)
"asarUnpack": [
"./node_modules/node-notifier/vendor/**",
"./res/icons/**"
],