1.环境搭建
npm init
npm i --save --dev node-gyp node-addon-api
在package.json中加入如下配置:
在package.json同级目录下创建配置文件binding.gyp:
{
"targets": [{
"target_name": "helloworld",
"cflags!": [ "-fno-exceptions" ],
"cflags_cc!": [ "-fno-exceptions" ],
"sources": [
"cppsrc/helloworld.cpp"
],
"include_dirs": [
"<!@(node -p \"require('node-addon-api').include\")"
],