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"