目录

How do I resolve the "Failed to generate NAPI, check the napi_init.cpp file and try again." error when using the Node-API generation feature?

Symptom

An error occurs for generating glue code when you right-click a function and choose Generate... > NAPI from the shortcut menu.

Solution

Make sure the napi_property_descriptor variable is properly initialized in the Init function of the napi_init.cpp file. If the variable is not initialized, add napi_property_descriptor desc[] = {}; and generate the Node-API again.