Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node.js C++ Addon Documentation #201

Closed
ann--b opened this issue Jul 28, 2022 · 3 comments
Closed

Node.js C++ Addon Documentation #201

ann--b opened this issue Jul 28, 2022 · 3 comments

Comments

@ann--b
Copy link

ann--b commented Jul 28, 2022

The above documentation refers the reader to this repo for the examples. But the first hello.cc example in the documentation doesn't match the 1_hello_world/node-addon-api example. The docs include <node.h> and the repo cc file includes <napi.h>. The repo file include line was added 5 years ago. I don't know which code is the most recent. I'm about to start reading the Node API Resource so maybe I can figure it out.

@ann--b
Copy link
Author

ann--b commented Jul 28, 2022

I think the Node.js documentation is using Node-API which is built into Node, and these examples are using the node-addon-api package. The Node API Resource did mention that not using this package will require additional coding, so that's why the code doesn't match.

@ann--b ann--b closed this as completed Jul 28, 2022
@NickNaso
Copy link
Member

Hi @ann--b,
Node-API is a C ABI stable API exported from the Node.js core and its documentation is in the core documentation https://nodejs.org/docs/latest/api/n-api.html. node-addon-api is a C++ wrapper around Node-API api.
The Node Addons Examples repo contains some examples written in nan, Node-API and node-addon-api if you need the example that use Node-API you should see in the napi folder.

@ann--b
Copy link
Author

ann--b commented Jul 28, 2022

Thank you @NickNaso. As a beginner I don't think I'm ready for the Node API and the core documentation. I will study the node-addon-api examples for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants