node C++插件使用,在我们常规使用中,需要使用node-gyp指定对饮的node版本即可
在electron的使用中,我们需要指定的是electron版本要不然会报错使用的v8内核版本不一致导致C++扩展无法正常引入
electron官方文档-node原生模块
package.json
{"devDependencies": {"@electron/rebuild": "^3.2.13","electron-rebuild": "^3.2.9"}
}
下面是我实现的调试编译bat脚本提供你参考
rd /s /q "./build"
node-gyp configure && node-gyp rebuild --target=25.5.0 --arch=x64 --dist-url=https://electronjs.org/headers
&& node "./node/test.js"