uiohook-napi
uiohook-napi copied to clipboard
Can not find module "uiohook-napi" after installation .exe
I am using electron forge with webpack and typescript, uiohook-napi is working properly in my development platform. Compiling the program is also working. But when I tried to install the .exe file this error is appearing.
My enviroment
uiohook-napi Version: ^1.5.3 Environment name and version: nodejs 20.9.0, electron: 29.1.5, electron-forge: ^7.3.1 Operating System and version: win32 x64
I think you need to force electron-forge to exclude uiohook-napi from the ASAR archive for it to work in packaged form. I am doing this using packagerConfig
in my forge configuration, see https://www.electronforge.io/config/configuration#electron-packager-config. You can explicitly specify uiohook-napi to not be packed in the ASAR using the asar
unpack
or unpackDir
options.
Hey @marcelblum, I appreciate your help. Unfortunately, I tried what you suggested, but I'm still encountering the same error 😔.
Sharing my forge.config file code for your reference. Could you please review it and let me know if I've made any mistakes? I'm relatively new to Electron, so I apologize in advance for any beginner errors.
Thanks again!
packagerConfig: {
asar: {
unpack: "node_modules/uiohook-napi/**", // Exclude uiohook-napi from ASAR
},
},
You can test it by looking in the folder structure of your packaged app to see if the files are outside the ASAR as desired. If successful you should find the excluded files under \resources\app.asar.unpacked\
. But actually if you want to exclude a whole folder you can use unpackDir
instead of unpack
. unpackDir: "node_modules/uiohook-napi"
should do it.
I have tried both unpackDir: "node_modules/uiohook-napi"
and unpack: "node_modules/uiohook-napi/**"
together as well as separately, but nothing works, stil the same error.
what i've tried so far:
asar: {
unpack: "node_modules/uiohook-napi/**", // Exclude uiohook-napi from ASAR
},
asar: {
unpackDir: "node_modules/uiohook-napi"
},
asar: {
unpack: "node_modules/uiohook-napi/**",
unpackDir: "node_modules/uiohook-napi"
},
I am using electron-forge make
command for creating packaged app and I cannot find \resources\app.asar.unpacked\
, I can only see \resources\app.asar
if you're not seeing a \resources\app.asar.unpacked
folder then something's not right in the way you have your packagerConfig
set up. Either the config is not being properly passed to forge or there's some syntax error or something. As a quick test you can just try asar: false
which should result in no asar being created, instead there should just be a \resources\app\
folder containing your source files (side note: this is also a good test to confirm that the asar was the problem preventing uiohook-napi from working in the first place). If you still have a \resources\app.asar
file even with asar: false
then your packagerConfig
is being ignored or overridden.
Hello all!
I'm having the same issue here: https://github.com/Dygmalab/Bazecor/tree/removeFocusAPI (open software with GPLv3 license so that you can compile it yourselves with yarn make)
I found this plugin from Forge to make use of the asar packager, but it fails either way. https://www.electronforge.io/config/plugins/auto-unpack-natives
This only fails in Windows platforms, in Mac it's working perfectly when packed.
@batoolfatima2135 did you manage to solve the issue on your side?
so, just for the record, I found the reason.
After updating xstate to v5, electron-forge started failing in the packaging process, to solve it, I had to update Typescript package from v4 to v5, but that broke the Windows native package's prebuilt binaries compilation.
The issue was within the filter in forge.config.ts at the packageAfterPrune function, and was due to a change in how the RegEx detected the prebuilds path to remove the precompiled binaries from other platforms than the one being compiled, it deleted them all, thus failing to execute when packaged.
Changing the filter to look for the platform independently solved this issue and maintained the optimization.
that's great you found solution @alexpargon, actually on my side I just used vite instead of webpack and it started working