https://github.com/richerfu/node-addon-api-ohos
node-addon-api for HarmonyOS/HarmonyNext
https://github.com/richerfu/node-addon-api-ohos
harmony harmonyos harmonyos-next n-api node-addon-api
Last synced: 9 months ago
JSON representation
node-addon-api for HarmonyOS/HarmonyNext
- Host: GitHub
- URL: https://github.com/richerfu/node-addon-api-ohos
- Owner: richerfu
- License: other
- Created: 2024-08-16T10:03:52.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-28T07:10:02.000Z (9 months ago)
- Last Synced: 2025-04-09T22:53:31.661Z (9 months ago)
- Topics: harmony, harmonyos, harmonyos-next, n-api, node-addon-api
- Language: C++
- Homepage:
- Size: 448 KB
- Stars: 8
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# node-addon-api-ohos
 [](https://opensource.org/licenses/MIT) 
`node-addon-api` for OpenHarmony/HarmonyNext.
We've made some Harmony-specific adaptations based on [node-addon-api](https://github.com/nodejs/node-addon-api), with the aim of providing the same development experience on the Harmony platform.
## Usage
### Install
```shell
ohpm install @ohos-rs/node-addon-api --save-dev
```
### Setup
Edit your `CMakeLists.txt` in your project and add those code:
```CMakeLists.txt
set(NODE_ADDON_API_OHOS_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules/@ohos-rs/node-addon-api)
set(CMAKE_MODULE_PATH ${NODE_ADDON_API_OHOS_ROOT_PATH})
find_package(node_addon_api_ohos REQUIRED)
target_link_libraries(entry PRIVATE node_addon_api_ohos)
```
## Environment
For node-addon-api-ohos, we acccepted the following environment variables:
| Name | Description | Default Value |
| --------------------------- | ----------------------------------------- | ------------- |
| NAPI_CPP_EXCEPTIONS | Allow catch the cpp exception | true |
| NAPI_DISABLE_CPP_EXCEPTIONS | Disable catch the cpp exception | false |
| NAPI_NORMAL | Hidden some APIs or cases for Harmony | true |
| NODE_GYP_MODULE_NAME | `NODE_API_ADDON` use it as library's name | |
## Build
You can release package locally. Just run command:
```shell
bash ./scripts/release.sh
```
It will generate a `.har` package in current path. You can import it with `file` protocol.
## Community
- [ohos-rs](https://github.com/ohos-rs/ohos-rs)