Swapnil Soni
Swapnil Soni

Reputation: 1049

Same Node.js version but gyp build uses different NODE_MODULE_VERSION

I have this project node-libcurl-impersonate I've ran npx node-gyp rebuild and moved my output to other project which is based on electron-react-boilerplate

I've moved the built dist from node-libcurl-impersonate to erb's main folder and used the lib from there and it's showing me the following error

[electronmon] waiting for a change to restart it
App threw an error during load
Error: The module '/home/sonisins/prujekts/node/drivetest-tool/src/main/lib/node-libcurl/lib/binding/node_libcurl-impersonate.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 93. This version of Node.js requires
NODE_MODULE_VERSION 103. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at process.func [as dlopen] (node:electron/js2c/asar_bundle:5:1812)
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1199:18)
    at Object.func [as .node] (node:electron/js2c/asar_bundle:5:1812)
    at Module.load (node:internal/modules/cjs/loader:988:32)
    at Module._load (node:internal/modules/cjs/loader:829:12)
    at Function.c._load (node:electron/js2c/asar_bundle:5:13343)
    at Function.Module._load (/home/sonisins/prujekts/node/drivetest-tool/node_modules/runtime-required/runtime-required.js:34:23)
    at Module.require (node:internal/modules/cjs/loader:1012:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/sonisins/prujekts/node/drivetest-tool/src/main/lib/node-libcurl/dist/Easy.js:5:18)
[electronmon] uncaught exception occured
[electronmon] waiting for any change to restart the app

The script in examples/chrome-impersonate.js runs fine after building the lib but not in electron project

Upvotes: 0

Views: 191

Answers (1)

OJ Kwon
OJ Kwon

Reputation: 4641

https://www.electronjs.org/docs/v14-x-y/tutorial/using-native-node-modules

Native Node.js modules are supported by Electron, but since Electron has a different application binary interface (ABI) from a given Node.js binary (due to differences such as using Chromium's BoringSSL instead of OpenSSL), the native modules you use will need to be recompiled for Electron. Otherwise, you will get the following class of error when you try to run your app:

Upvotes: 1

Related Questions