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

How to require another built-in module? #505

Closed
thestrangedev opened this issue Jun 27, 2019 · 2 comments
Closed

How to require another built-in module? #505

thestrangedev opened this issue Jun 27, 2019 · 2 comments

Comments

@thestrangedev
Copy link

I need to use some modules like fs or crypto. It's easy for me to achieve that with Nan by using module varible. Is there any way to do the same?

@gabrielschulhof
Copy link
Contributor

You can write a function that accepts another module. Here's a gist with an example.

gabrielschulhof pushed a commit to gabrielschulhof/node that referenced this issue Jun 28, 2019
We make the `napi_env` per-module once more because it no longer
holds any state that needs to be shared among add-ons.

We then add a Node.js-specific N-API which allows one to obtain the
module whose exports were initialized at addon startup.

Re: nodejs/node-addon-api#449
Re: nodejs/node-addon-api#482
Re: nodejs/node-addon-api#505
@mhdawson
Copy link
Member

mhdawson commented Dec 7, 2020

Going to close this out as the question was answered and there was no follow on question. Please let us know if that was not the right thing to do.

@mhdawson mhdawson closed this as completed Dec 7, 2020
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

3 participants