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 run the .exe file error "Cannot find module 'uiohook-napi" is appearing.
module: uiohook-napi
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
My webpack config:
import type { Configuration } from "webpack";
import { rules } from "./webpack.rules";
import { plugins } from "./webpack.plugins";
export const mainConfig: Configuration = {
/**
* This is the main entry point for your application, it's the first file
* that runs in the main process.
*/
entry: "./src/index.ts",
// Put your normal webpack config below here
module: {
rules,
},
externals: ["electron", "uiohook-napi"],
plugins,
resolve: {
extensions: [".js", ".ts", ".jsx", ".tsx", ".css", ".json"],
},
};
I tried 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 like:
packagerConfig: {
asar: {
unpack: "node_modules/uiohook-napi/**",
unpackDir: "node_modules/uiohook-napi", // Exclude uiohook-napi from ASAR
},
},
note: I'm relatively new to Electron, so I apologize in advance for any beginner errors.