napi_get_node_version


typedef struct {
  uint32_t major;
  uint32_t minor;
  uint32_t patch;
  const char* release;
} napi_node_version;

napi_status napi_get_node_version(node_api_basic_env env,
                                  const napi_node_version** version); 
  • [in] env:调用该 API 时所处的环境。
  • [out] version:指向 Node.js 本身版本信息的指针。

如果 API 成功,则返回 napi_ok

【Returns napi_ok if the API succeeded.】

此函数会将当前运行的 Node.js 的主版本、次版本和补丁版本填充到 version 结构中,并将 release 字段填充为 process.release.name 的值。

【This function fills the version struct with the major, minor, and patch version of Node.js that is currently running, and the release field with the value of process.release.name.】

返回的缓冲区是静态分配的,不需要释放。

【The returned buffer is statically allocated and does not need to be freed.】