Incomplete type error for napi.h – C++ addon for Node

  add-on, c++, incomplete-type, node.js, visual-studio

I am creating C++ addons for Node and everything works good except Visual Studio is underlying all types from napi.h library and telling me that incomplete types are not allowed. When I compile it with node-gyp, everything is alright, but its little bit disturbing to see so many "reds" in my code in Visual Studio.

#include "test.h"
#include "../node_modules/node-addon-api/napi.h"


Napi::String helloFunc(const Napi::CallbackInfo& info) {
    Napi::Env env = info.Env();

    std::string name = (std::string)info[0].ToString();
    std::string result = helloUser(name);
    
    return Napi::String::New(env, result);
 }

Napi::Object Init(Napi::Env env, Napi::Object exports) {
    exports.Set(
        Napi::String::New(env, "helloUser"),
        Napi::Function::New(env, helloFunc)
    );

    return exports;
}


NODE_API_MODULE(greet, Init)

Source: Windows Questions C++

LEAVE A COMMENT