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

Cannot use Env::SetInstanceData #810

Closed
kaysonwu opened this issue Sep 8, 2020 · 3 comments
Closed

Cannot use Env::SetInstanceData #810

kaysonwu opened this issue Sep 8, 2020 · 3 comments

Comments

@kaysonwu
Copy link

kaysonwu commented Sep 8, 2020

napi_set_instance_data Added in: v12.8.0, v10.20.0 N-API version: 6.

The following is my version information:

nodejs: 12.14.1
NAPI_VERSION: 5

@kaysonwu kaysonwu changed the title Cannot use SetInstanceData Cannot use Env::SetInstanceData Sep 8, 2020
@kaysonwu
Copy link
Author

kaysonwu commented Sep 8, 2020

Currently using NAPI_VERSION judgment, so I cannot use Env::SetInstanceData.

@NickNaso
Copy link
Member

NickNaso commented Sep 8, 2020

Hi @kaysonwu,
the function napi_set_instance_data was added for the first time in Node.js version v12.8.0 and v10.20.0. At that time the function was considered like experimental and then it has been promoted like stable api with N-API version 6.
You should always refer to NAPI_VERSION to identify what function is available.
In you specific case the function was available, but experimental so you can try to set NAPI_VERSION to 6 and define the NAPI_EXPERIMENTAL.
In your binding.gyp file:

{
   "targets": [
        {
            "defines": [ "NAPI_EXPERIMENTAL", "NAPI_VERSION=6" ],
        }
   ]
}

I hope that this help you.

@kaysonwu
Copy link
Author

kaysonwu commented Sep 9, 2020

thanks!

@kaysonwu kaysonwu closed this as completed Sep 9, 2020
mhdawson added a commit to mhdawson/io.js that referenced this issue Sep 14, 2020
We've had a few questions about APIs not being available which
were related to not having specified `NAPI_EXPERIMENTAL`.

Add some additional documentation to explain this common
issue:

Refs: nodejs/node-addon-api#810

Signed-off-by: Michael Dawson <mdawson@devrus.com>
mhdawson added a commit to nodejs/node that referenced this issue Sep 18, 2020
We've had a few questions about APIs not being available which
were related to not having specified `NAPI_EXPERIMENTAL`.

Add some additional documentation to explain this common
issue:

Refs: nodejs/node-addon-api#810

Signed-off-by: Michael Dawson <mdawson@devrus.com>

PR-URL: #35195
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
ruyadorno pushed a commit to nodejs/node that referenced this issue Sep 21, 2020
We've had a few questions about APIs not being available which
were related to not having specified `NAPI_EXPERIMENTAL`.

Add some additional documentation to explain this common
issue:

Refs: nodejs/node-addon-api#810

Signed-off-by: Michael Dawson <mdawson@devrus.com>

PR-URL: #35195
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
addaleax pushed a commit to nodejs/node that referenced this issue Sep 22, 2020
We've had a few questions about APIs not being available which
were related to not having specified `NAPI_EXPERIMENTAL`.

Add some additional documentation to explain this common
issue:

Refs: nodejs/node-addon-api#810

Signed-off-by: Michael Dawson <mdawson@devrus.com>

PR-URL: #35195
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
joesepi pushed a commit to joesepi/node that referenced this issue Jan 8, 2021
We've had a few questions about APIs not being available which
were related to not having specified `NAPI_EXPERIMENTAL`.

Add some additional documentation to explain this common
issue:

Refs: nodejs/node-addon-api#810

Signed-off-by: Michael Dawson <mdawson@devrus.com>

PR-URL: nodejs#35195
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
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