0

我正在尝试使用最新版本的节点在 Windows 上编译这个较旧的npm 包,它抛出了一些我不理解的 C 编译器错误。任何帮助理解这些错误以及如何解决它们将不胜感激。

这是引发错误的文件:

#include <node.h>
#include <v8.h>
#include <Windows.h>
#include <iostream>

#include "WINTAB.H"

#include "Utils.h"
char* gpszProgramName = "node_wintab";

#include "MSGPACK.H"

#define PACKETDATA (PK_X | PK_Y | PK_NORMAL_PRESSURE | PK_STATUS | PK_ORIENTATION)
#define PACKETMODE PK_BUTTONS
#include "PKTDEF.H"

using namespace v8;
using namespace std;

int pen_x = -1;
int pen_y = -1;
int pen_pressure = -1;
int pressure_min = -1;
int pressure_max = -1;
bool is_eraser = FALSE;
int azimuth = 0;
int altitude = 0;
int twist = 0;
int azimuth_min = -1;
int azimuth_max = -1;
int altitude_min = -1;
int altitude_max = -1;

void get_pressure(const FunctionCallbackInfo<Value>& info) {
    if (pen_pressure < 0) {
        info.GetReturnValue().SetNull();
    } else {
        info.GetReturnValue().Set(pen_pressure);
    }
}

void get_pen_x(const FunctionCallbackInfo<Value>& info) {
    info.GetReturnValue().Set(pen_x);
}

void get_pen_y(const FunctionCallbackInfo<Value>& info) {
    info.GetReturnValue().Set(pen_y);
}

void get_azimuth(const FunctionCallbackInfo<Value>& info) {
    info.GetReturnValue().Set(azimuth);
}

void get_altitude(const FunctionCallbackInfo<Value>& info) {
    info.GetReturnValue().Set(altitude);
}

void get_twist(const FunctionCallbackInfo<Value>& info) {
    info.GetReturnValue().Set(twist);
}

void get_azimuth_min(const FunctionCallbackInfo<Value>& info) {
    info.GetReturnValue().Set(azimuth_min);
}

void get_azimuth_max(const FunctionCallbackInfo<Value>& info) {
    info.GetReturnValue().Set(azimuth_max);
}

void get_altitude_min(const FunctionCallbackInfo<Value>& info) {
    info.GetReturnValue().Set(altitude_min);
}

void get_altitude_max(const FunctionCallbackInfo<Value>& info) {
    info.GetReturnValue().Set(altitude_max);
}

void get_pressure_min(const FunctionCallbackInfo<Value>& info) {
    if (pressure_min < 0) {
        info.GetReturnValue().SetNull();
    }
    else {
        info.GetReturnValue().Set(pressure_min);
    }
}

void get_pressure_max(const FunctionCallbackInfo<Value>& info) {
    if (pressure_max < 0) {
        info.GetReturnValue().SetNull();
    }
    else {
        info.GetReturnValue().Set(pressure_max);
    }
}

void check_eraser(const FunctionCallbackInfo<Value>& info) {
    info.GetReturnValue().Set(is_eraser);
}

HINSTANCE hinst;
WNDCLASS wc;
HWND hwnd;

HCTX hctx;
LOGCONTEXT lc = {0};

bool overlapped = FALSE;

void peek_message(const FunctionCallbackInfo<Value>& info) {
    MSG msg;
    while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    info.GetReturnValue().SetUndefined();
}

void check_overlapped(const FunctionCallbackInfo<Value>& info) {
    bool tmp = overlapped;
    overlapped = FALSE;
    info.GetReturnValue().Set(tmp);
}

void enable_context(const FunctionCallbackInfo<Value>& info) {
    if (hctx) {
        gpWTEnable(hctx, TRUE);
        gpWTOverlap(hctx, TRUE);
    }
    info.GetReturnValue().SetUndefined();
}

HCTX initTablet(HWND hwnd) {
    AXIS TabletX = {0};
    AXIS TabletY = {0};
    AXIS Pressure = {0};
    lc.lcOptions |= CXO_SYSTEM;
    if (gpWTInfoA(WTI_DEFSYSCTX, 0, &lc) != sizeof(LOGCONTEXT))
        return (HCTX) NULL;
    if (!(lc.lcOptions & CXO_SYSTEM))
        return (HCTX) NULL;
    wsprintf(lc.lcName, "node_wintab_%x", hinst);
    lc.lcPktData = PACKETDATA;
    lc.lcOptions |= CXO_MESSAGES;
    lc.lcPktMode = PACKETMODE;
    lc.lcMoveMask = PACKETDATA;
    lc.lcBtnUpMask = lc.lcBtnDnMask;
    if (gpWTInfoA(WTI_DEVICES, DVC_X, &TabletX) != sizeof(AXIS))
        return (HCTX) NULL;
    if (gpWTInfoA(WTI_DEVICES, DVC_Y, &TabletY) != sizeof(AXIS))
        return (HCTX) NULL;
    if (gpWTInfoA(WTI_DEVICES, DVC_NPRESSURE, &Pressure) != sizeof(AXIS))
        return (HCTX) NULL;
    lc.lcInOrgX = 0;
    lc.lcInOrgY = 0;
    lc.lcInExtX = TabletX.axMax;
    lc.lcInExtY = TabletY.axMax;
    lc.lcOutOrgX = 0;
    lc.lcOutOrgY = 0;
    lc.lcOutExtX = GetSystemMetrics(SM_CXSCREEN);
    lc.lcOutExtY = -GetSystemMetrics(SM_CYSCREEN);
    lc.lcSysOrgX = 0;
    lc.lcSysOrgY = 0;
    lc.lcSysExtX = GetSystemMetrics(SM_CXSCREEN);
    lc.lcSysExtY = GetSystemMetrics(SM_CYSCREEN);

    pressure_min = (int) Pressure.axMin;
    pressure_max = (int) Pressure.axMax;

    struct tagAXIS tiltOrient[3];
    BOOL tiltSupport = FALSE;
    tiltSupport = gpWTInfoA(WTI_DEVICES, DVC_ORIENTATION, &tiltOrient);
    if (tiltSupport )
    {
        // Does the tablet support azimuth and altitude
        if (tiltOrient[0].axResolution && tiltOrient[1].axResolution)
        {
            // Get resolution
            azimuth_min = tiltOrient[0].axMin;
            azimuth_max = tiltOrient[0].axMax;
            altitude_min = tiltOrient[1].axMin;
            altitude_max = tiltOrient[1].axMax;
        }
        else
        {
            tiltSupport = FALSE;
        }
    }

    return gpWTOpenA(hwnd, &lc, TRUE);
}

LRESULT msgLoop(HWND hwnd, unsigned msg, WPARAM wp, LPARAM lp) {
    PACKET pkt;
    switch (msg) {
    case WM_CREATE:
        hctx = initTablet(hwnd);
        break;
    case WM_NCCREATE:
        break;
    case WT_PACKET:
        if (gpWTPacket((HCTX) lp, wp, &pkt)) {
            pen_x = (int) pkt.pkX;
            pen_y = (int) pkt.pkY;
            pen_pressure = (int) pkt.pkNormalPressure;
            is_eraser = (bool) (pkt.pkStatus & TPS_INVERT);
            azimuth = (int) pkt.pkOrientation.orAzimuth;
            altitude = (int) pkt.pkOrientation.orAltitude;
            twist = (int) pkt.pkOrientation.orTwist;
        }
        break;
    case WT_CTXOVERLAP:
        overlapped = TRUE;
        break;
    case WT_PROXIMITY:
        pen_x = -1;
        pen_y = -1;
        pen_pressure = -1;
        is_eraser = FALSE;
        azimuth = -1;
        altitude = -1;
        twist = -1;
        break;
    default:
        return (LRESULT) 0L;
    }
    return DefWindowProc(hwnd, msg, wp, lp);
}

void init(Local<Object> exports) {
    hinst = (HINSTANCE) GetModuleHandle(NULL);
    wc.style = 0;
    wc.lpfnWndProc = (WNDPROC) msgLoop;
    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;
    wc.hInstance = hinst;
    wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH) (COLOR_APPWORKSPACE + 1);
    wc.lpszMenuName =  "wintabMenu";
    wc.lpszClassName = "wintabClass";
    RegisterClass(&wc);
    LoadWintab();
    hwnd = CreateWindow(
        "wintabClass",
        "wintabWindow",
        WS_OVERLAPPED, CW_USEDEFAULT, CW_USEDEFAULT,
        CW_USEDEFAULT, CW_USEDEFAULT, (HWND) NULL,
        (HMENU) NULL, hinst, (LPVOID) NULL
    );
    Isolate* isolate = Isolate::GetCurrent();
    exports->Set(String::NewFromUtf8(isolate, "pressure"), FunctionTemplate::New(isolate, get_pressure)->GetFunction());
    exports->Set(String::NewFromUtf8(isolate, "x"), FunctionTemplate::New(isolate, get_pen_x)->GetFunction());
    exports->Set(String::NewFromUtf8(isolate, "y"), FunctionTemplate::New(isolate, get_pen_y)->GetFunction());
    exports->Set(String::NewFromUtf8(isolate, "azimuth"), FunctionTemplate::New(isolate, get_azimuth)->GetFunction());
    exports->Set(String::NewFromUtf8(isolate, "altitude"), FunctionTemplate::New(isolate, get_altitude)->GetFunction());
    exports->Set(String::NewFromUtf8(isolate, "twist"), FunctionTemplate::New(isolate, get_twist)->GetFunction());
    exports->Set(String::NewFromUtf8(isolate, "azimuthMin"), FunctionTemplate::New(isolate, get_azimuth_min)->GetFunction());
    exports->Set(String::NewFromUtf8(isolate, "azimuthMax"), FunctionTemplate::New(isolate, get_azimuth_max)->GetFunction());
    exports->Set(String::NewFromUtf8(isolate, "altitudeMin"), FunctionTemplate::New(isolate, get_altitude_min)->GetFunction());
    exports->Set(String::NewFromUtf8(isolate, "altitudeMax"), FunctionTemplate::New(isolate, get_altitude_max)->GetFunction());
    exports->Set(String::NewFromUtf8(isolate, "minPressure"), FunctionTemplate::New(isolate, get_pressure_min)->GetFunction());
    exports->Set(String::NewFromUtf8(isolate, "maxPressure"), FunctionTemplate::New(isolate, get_pressure_max)->GetFunction());
    exports->Set(String::NewFromUtf8(isolate, "isEraser"), FunctionTemplate::New(isolate, check_eraser)->GetFunction());
    exports->Set(String::NewFromUtf8(isolate, "peekMessage"), FunctionTemplate::New(isolate, peek_message)->GetFunction());
    exports->Set(String::NewFromUtf8(isolate, "checkOverlapped"), FunctionTemplate::New(isolate, check_overlapped)->GetFunction());
    exports->Set(String::NewFromUtf8(isolate, "enableContext"), FunctionTemplate::New(isolate, enable_context)->GetFunction());
}

NODE_MODULE(wintab, init)

我得到的错误如下:

C:\Users\Username\path-to-app\node_modules\wintab-2020\wintab.cc(253,118): error C2660:
'v8::FunctionTemplate::GetFunction': function does not take 0 arguments [path-to-app\node_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\AppData\Local\node-gyp\Cache\12.14.0\include\node\v8.h(5995,46): message : see declaration of 'v8::Funct
ionTemplate::GetFunction' (compiling source file ..\wintab.cc) [C:\Users\Username\path-to-app\node_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\path-to-app\node_modules\wintab-2020\wintab.cc(253,119): error C2661:
'v8::Object::Set': no overloaded function takes 1 arguments [C:\Users\Username\path-to-appnode_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\path-to-app\node_modules\wintab-2020\wintab.cc(254,108): error C2660:
'v8::FunctionTemplate::GetFunction': function does not take 0 arguments [path-to-app\node_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\AppData\Local\node-gyp\Cache\12.14.0\include\node\v8.h(5995,46): message : see declaration of 'v8::Funct
ionTemplate::GetFunction' (compiling source file ..\wintab.cc) [C:\Users\Username\path-to-app\node_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\path-to-app\node_modules\wintab-2020\wintab.cc(254,109): error C2661:
'v8::Object::Set': no overloaded function takes 1 arguments [C:\Users\Username\path-to-appnode_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\path-to-app\node_modules\wintab-2020\wintab.cc(255,108): error C2660:
'v8::FunctionTemplate::GetFunction': function does not take 0 arguments [path-to-app\node_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\AppData\Local\node-gyp\Cache\12.14.0\include\node\v8.h(5995,46): message : see declaration of 'v8::Funct
ionTemplate::GetFunction' (compiling source file ..\wintab.cc) [C:\Users\Username\path-to-app\node_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\path-to-app\node_modules\wintab-2020\wintab.cc(255,109): error C2661:
'v8::Object::Set': no overloaded function takes 1 arguments [C:\Users\Username\path-to-appnode_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\path-to-app\node_modules\wintab-2020\wintab.cc(256,116): error C2660:
'v8::FunctionTemplate::GetFunction': function does not take 0 arguments [path-to-app\node_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\AppData\Local\node-gyp\Cache\12.14.0\include\node\v8.h(5995,46): message : see declaration of 'v8::Funct
ionTemplate::GetFunction' (compiling source file ..\wintab.cc) [C:\Users\Username\path-to-app\node_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\path-to-app\node_modules\wintab-2020\wintab.cc(256,117): error C2661:
'v8::Object::Set': no overloaded function takes 1 arguments [C:\Users\Username\path-to-appnode_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\path-to-app\node_modules\wintab-2020\wintab.cc(257,118): error C2660:
'v8::FunctionTemplate::GetFunction': function does not take 0 arguments [path-to-app\node_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\AppData\Local\node-gyp\Cache\12.14.0\include\node\v8.h(5995,46): message : see declaration of 'v8::Funct
ionTemplate::GetFunction' (compiling source file ..\wintab.cc) [C:\Users\Username\\cadmiu
m-app\node_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\path-to-app\node_modules\wintab-2020\wintab.cc(257,119): error C2661:
'v8::Object::Set': no overloaded function takes 1 arguments [C:\Users\Username\path-to-appnode_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\path-to-app\node_modules\wintab-2020\wintab.cc(258,112): error C2660:
'v8::FunctionTemplate::GetFunction': function does not take 0 arguments [path-to-app\node_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\AppData\Local\node-gyp\Cache\12.14.0\include\node\v8.h(5995,46): message : see declaration of 'v8::Funct
ionTemplate::GetFunction' (compiling source file ..\wintab.cc) [C:\Users\Username\path-to-app\node_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\path-to-app\node_modules\wintab-2020\wintab.cc(258,113): error C2661:
'v8::Object::Set': no overloaded function takes 1 arguments [C:\Users\Username\path-to-appnode_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\path-to-app\node_modules\wintab-2020\wintab.cc(259,123): error C2660:
'v8::FunctionTemplate::GetFunction': function does not take 0 arguments [path-to-app\node_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\AppData\Local\node-gyp\Cache\12.14.0\include\node\v8.h(5995,46): message : see declaration of 'v8::Funct
ionTemplate::GetFunction' (compiling source file ..\wintab.cc) [C:\Users\Username\path-to-app\node_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\path-to-app\node_modules\wintab-2020\wintab.cc(259,124): error C2661:
'v8::Object::Set': no overloaded function takes 1 arguments [C:\Users\Username\path-to-appnode_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\path-to-app\node_modules\wintab-2020\wintab.cc(260,123): error C2660:
'v8::FunctionTemplate::GetFunction': function does not take 0 arguments [path-to-app\node_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\AppData\Local\node-gyp\Cache\12.14.0\include\node\v8.h(5995,46): message : see declaration of 'v8::Funct
ionTemplate::GetFunction' (compiling source file ..\wintab.cc) [C:\Users\Username\path-to-app\node_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\path-to-app\node_modules\wintab-2020\wintab.cc(260,124): error C2661:
'v8::Object::Set': no overloaded function takes 1 arguments [C:\Users\Username\path-to-appnode_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\path-to-app\node_modules\wintab-2020\wintab.cc(261,125): error C2660:
'v8::FunctionTemplate::GetFunction': function does not take 0 arguments [path-to-app\node_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\AppData\Local\node-gyp\Cache\12.14.0\include\node\v8.h(5995,46): message : see declaration of 'v8::Funct
ionTemplate::GetFunction' (compiling source file ..\wintab.cc) [C:\Users\Username\path-to-app\node_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\path-to-app\node_modules\wintab-2020\wintab.cc(261,126): error C2661:
'v8::Object::Set': no overloaded function takes 1 arguments [C:\Users\Username\path-to-appnode_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\path-to-app\node_modules\wintab-2020\wintab.cc(262,125): error C2660:
'v8::FunctionTemplate::GetFunction': function does not take 0 arguments [path-to-app\node_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\AppData\Local\node-gyp\Cache\12.14.0\include\node\v8.h(5995,46): message : see declaration of 'v8::Funct
ionTemplate::GetFunction' (compiling source file ..\wintab.cc) [C:\Users\Username\path-to-app\node_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\path-to-app\node_modules\wintab-2020\wintab.cc(262,126): error C2661:
'v8::Object::Set': no overloaded function takes 1 arguments [C:\Users\Username\path-to-appnode_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\path-to-app\node_modules\wintab-2020\wintab.cc(263,125): error C2660:
'v8::FunctionTemplate::GetFunction': function does not take 0 arguments [path-to-app\node_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\AppData\Local\node-gyp\Cache\12.14.0\include\node\v8.h(5995,46): message : see declaration of 'v8::Funct
ionTemplate::GetFunction' (compiling source file ..\wintab.cc) [C:\Users\Username\path-to-app\node_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\path-to-app\node_modules\wintab-2020\wintab.cc(263,126): error C2661:
'v8::Object::Set': no overloaded function takes 1 arguments [C:\Users\Username\path-to-appnode_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\path-to-app\node_modules\wintab-2020\wintab.cc(264,125): error C2660:
'v8::FunctionTemplate::GetFunction': function does not take 0 arguments [path-to-app\node_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\AppData\Local\node-gyp\Cache\12.14.0\include\node\v8.h(5995,46): message : see declaration of 'v8::Funct
ionTemplate::GetFunction' (compiling source file ..\wintab.cc) [C:\Users\Username\path-to-app\node_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\path-to-app\node_modules\wintab-2020\wintab.cc(264,126): error C2661:
'v8::Object::Set': no overloaded function takes 1 arguments [C:\Users\Username\path-to-appnode_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\path-to-app\node_modules\wintab-2020\wintab.cc(265,118): error C2660:
'v8::FunctionTemplate::GetFunction': function does not take 0 arguments [path-to-app\node_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\AppData\Local\node-gyp\Cache\12.14.0\include\node\v8.h(5995,46): message : see declaration of 'v8::Funct
ionTemplate::GetFunction' (compiling source file ..\wintab.cc) [C:\Users\Username\path-to-app\node_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\path-to-app\node_modules\wintab-2020\wintab.cc(265,119): error C2661:
'v8::Object::Set': no overloaded function takes 1 arguments [C:\Users\Username\path-to-appnode_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\path-to-app\node_modules\wintab-2020\wintab.cc(266,121): error C2660:
'v8::FunctionTemplate::GetFunction': function does not take 0 arguments [path-to-app\node_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\AppData\Local\node-gyp\Cache\12.14.0\include\node\v8.h(5995,46): message : see declaration of 'v8::Funct
ionTemplate::GetFunction' (compiling source file ..\wintab.cc) [C:\Users\Username\path-to-app\node_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\path-to-app\node_modules\wintab-2020\wintab.cc(266,122): error C2661:
'v8::Object::Set': no overloaded function takes 1 arguments [C:\Users\Username\path-to-appnode_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\path-to-app\node_modules\wintab-2020\wintab.cc(267,129): error C2660:
'v8::FunctionTemplate::GetFunction': function does not take 0 arguments [path-to-app\node_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\AppData\Local\node-gyp\Cache\12.14.0\include\node\v8.h(5995,46): message : see declaration of 'v8::Funct
ionTemplate::GetFunction' (compiling source file ..\wintab.cc) [C:\Users\Username\path-to-app\node_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\path-to-app\node_modules\wintab-2020\wintab.cc(267,130): error C2661:
'v8::Object::Set': no overloaded function takes 1 arguments [C:\Users\Username\path-to-appnode_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\path-to-app\node_modules\wintab-2020\wintab.cc(268,125): error C2660:
'v8::FunctionTemplate::GetFunction': function does not take 0 arguments [path-to-app\node_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\AppData\Local\node-gyp\Cache\12.14.0\include\node\v8.h(5995,46): message : see declaration of 'v8::Funct
ionTemplate::GetFunction' (compiling source file ..\wintab.cc) [C:\Users\Username\path-to-app\node_modules\wintab-2020\build\wintab.vcxproj]
C:\Users\Username\path-to-app\node_modules\wintab-2020\wintab.cc(268,126): error C2661:
'v8::Object::Set': no overloaded function takes 1 arguments [C:\Users\Username\path-to-appnode_modules\wintab-2020\build\wintab.vcxproj]
4

1 回答 1

0

以前的 node.js 版本正在维护这些 API,但这些都被标记为已弃用。在 node.js v12 中,他们删除了这些已弃用的 API。

现在 v8::FunctionTemplate::GetFunction() 采用一个参数,即上下文。以前 GetFunction 用于返回 Local Local<Function> GetFunction()现在它返回 MaybeLocal MaybeLocal<Function> GetFunction (Local<Context> context)所以我们必须使用 .ToLocalChecked() 将此 MaybeLocal 转换为 Local :

因此,您可以使用以下代码更新您的 GetFunction(): v8::FunctionTemplate::GetFunction(Nan::GetCurrentContext()).ToLocalChecked()

对于 Node 12 https://v8docs.nodesource.com/node-12.16/d2/dc3/namespacev8.html,您也可以参考本文档以了解其他问题

于 2020-08-13T08:45:56.337 回答