I have an electron app and I also use node-gyp to use some native C++ functions.
I first execute npm run build:gyp and then npm run start and everything works fine.
{
"scripts": {
"start": "electron .",
"build": "electron-builder -w",
"build:gyp": "node-gyp rebuild"
},
"devDependencies": {
"electron": "^20.1.4",
"electron-builder": "^23.3.3",
"node-gyp": "^9.1.0"
},
}
but after I build electron app, it can not find testaddone.node file in node-gyp build folder.
Error: Cannot find module '../build/Release/testaddon.node'
This is where I require napi generated file:
const testAddon = require('../build/Release/testaddon.node');
exports.Halcon_init = function () {
return new Promise((resolve, reject) => {
console.log('Initialization ', testAddon.Initialization());
resolve()
})
}
I read this(I thought it is helpful): using-native-node-modules#manually-building-for-electron
but I did not figure out how to use it correctly.