Reputation: 245
I am trying to upgrade my application from electron 1.8.1 to 4.0.6. I am using multiple native node js modules. They all compile successfully (or prebuilt binaries are available).
I am getting following error when requiring one of the modules.
XXXX\node_modules\electron-log\renderer.js:34 [10:14:51.109] Failed to add
module. Error: Error: The specified procedure could not be found.
\?\XXXXX\node_modules\pc-ble-driver-js\build\Release\pc-ble-driver-js-
sd_api_v2.node
Whereas other native modules (such as serialport, noble-uwp) are loading and working fine.
This error generally indicates that a required DLL is missing. I have used Dependency Walker (http://www.dependencywalker.com/) to check the dependencies but I couldn't nail down the error. I tried to compare dependencies for module that works and the one for which I get above error. I didn't see obvious differences.
I have Visual Studio 2015 installed. I also have VC++ 2015 redistributable installed.
My electron specific dependencies are:
"devDependencies": {
"electron": "~4.0.6",
"electron-builder": "~20.39.0",
"electron-rebuild": "^1.8.4"
},
I am using node-js 10.15.3.
I have noticed that till electron 3, node_modules/electron/dist had many DLLs present. These DLLs are not present with electron 4.
Are any additional dependencies needed to be installed for native modules to work with electron 4?
Upvotes: 2
Views: 2107
Reputation: 245
I got this to work.
For native node js modules to work with electron 4 on Windows, it needs to be compiled with "Delay Load Hook". More info: https://electronjs.org/docs/tutorial/using-native-node-modules#a-note-about-win_delay_load_hook and https://github.com/nodejs/node-addon-api/issues/269#issuecomment-455580129. After making these changes my failing module started to work.
About why other modules worked without these changes is because they use node-gyp directly. It takes care of using this hook.
My failing module uses cmake-js, which needs above mentioned additional changes.
Upvotes: 3