Native node module could not be found in asar


#1

I use native node module which depends on another library. The module and the library are located inside the subfolder of the application:

app
    |- package.json
    |- index.html
    |- main.js
    |- modules
        |- mymodule.node
        |- somelib.dll

When I pack the app by electron-packager without --asar switch then the app works. But if I use --asar switch and run the app then I get such error

Uncaught Error: The specified module could not be found.
C:\Users\myusername\AppData\Local\Temp\D7C1.tmp

where the D7C1.tmp is copied binary file of mymodule.node. Seems the native module cannot find the library which is dependent on. How to solve it?


#2

The solution is --asar-unpack:

--asar-unpack="*.+(node|dll)"

but strange I cannot specify also the directory inside the pattern. The option below does not match any file from my file structure :confused:

--asar-unpack="modules/*.+(node|dll)"