node-notifier icon indicating copy to clipboard operation
node-notifier copied to clipboard

Does not show icon after being packed in asar

Open Mxdi opened this issue 6 years ago • 10 comments

So as said , using electron-packager, it does not show the icon.

Mxdi avatar Dec 25 '18 02:12 Mxdi

Using the --asar=true property in electron-packager, does not allow for the icon to show.

Mxdi avatar Dec 30 '18 01:12 Mxdi

Have you seen this guide? https://github.com/mikaelbr/node-notifier#within-electron-packaging

mikaelbr avatar Jan 24 '19 11:01 mikaelbr

So what is my webpack? I dont have one of those?

Mxdi avatar Jan 24 '19 15:01 Mxdi

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.

mikaelbr avatar Jan 24 '19 15:01 mikaelbr

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?

Mxdi avatar Jan 24 '19 16:01 Mxdi

Also I have followed this 'guide', I installed asar globally, Packed the app. And still no icon.

Mxdi avatar Jan 24 '19 16:01 Mxdi

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.

Mxdi avatar Jan 24 '19 16:01 Mxdi

--asar.unpack="node_modules/node-notifier/vendor/**" - This works

However, The icon for the notification is still not appearing.

Mxdi avatar Jan 24 '19 18:01 Mxdi

--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:

image

and we have absolute path to the icon

notifier.notify(
    {
         icon: path.join(__dirname, '../some-icon.png'),
    }
);

and icon is show in notification

burasuk avatar May 01 '20 21:05 burasuk

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/**"
        ],

RoderickQiu avatar Jun 05 '21 00:06 RoderickQiu