node-addon-api
설치
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - \
&& sudo apt-get install -y nodejs
mkdir test \
&& cd test \
&& npm init
sudo npm install -g node-gyp
npm install node-addon-api
Setup
<package>
├── binding.gyp
├── index.js
├── node_modules
│ └── node-addon-api
│ └── ...
├── package.json
├── package-lock.json
├── test
│ └── ...
├── .clang-format
└── c_src
├── funcs.cpp
├── funcs.h
├── funcs_wrapper.cpp
├── funcs_wrapper.h
└── <target>.cpp
package.json
{
"name": "<package>",
# ...
"gypfile": true,
# ...
"scripts": {
"install": "node-gyp rebuild",
"build": "node-gyp rebuild --verbose",
"clean": "node-gyp clean",
"cf": "clang-format -style=file -i -verbose c_src/*"
},
# ...
"dependencies": {
"node-addon-api": "*",
},
# ...
}