nodejs / node-gyp

Node.js native addon build tool

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

some suggestions about node-gyp build command

Need-an-AwP opened this issue · comments

i was trying to export an int after successfully export str and array with v8 api, and i got this weird error in building process.
in this part of my exported function, i can use args.GetReturnValue().Set() to export a str like example code in doc.
but when i tried to use args.GetReturnValue().Set() to export v8's integer type value or int32 type value, this will happen in build process. i can't get any useful infomation form the error output.

void mainMethod(const v8::FunctionCallbackInfo<v8::Value> &args)
{
    DWORD processId = 14620;
    v8::Isolate *isolate = args.GetIsolate();
    int32_t intProcessId = static_cast<int32_t>(processId); // convert DWORD to int32_t
    //args.GetReturnValue().Set(v8::Integer::New(isolate, intProcessId));
    args.GetReturnValue().Set(v8::Integer::New(isolate, 123123));
}

then i found that it is necessary to use node-gyp configure everytime when a function's export content changes, or this error will occurr. so i am using node-gyp configure && node-gyp build when building addon. sometimes i also need to delete the whole 'build' folder which is created by node-gyp configure

i hope some instructions coulde be added in somewhere like 'how to use' part of readme page

Verbose output (from npm or node-gyp):
$ node-gyp build
gyp info it worked if it ends with ok
gyp info using node-gyp@10.1.0
gyp info using node@18.18.0 | win32 | x64
gyp info spawn C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe
gyp info spawn args [
gyp info spawn args 'build\\binding.sln',
gyp info spawn args '/clp:Verbosity=minimal',
gyp info spawn args '/nologo',
gyp info spawn args '/p:Configuration=Release;Platform=x64'
gyp info spawn args ]

  test.cc
  正在生成代码
  0 of 313 functions ( 0.0%) were compiled, the rest were copied from previous compilation.
    0 functions were new in current compilation
    0 functions had inline decision re-evaluated but remain unchanged
  已完成代码的生成
kernel32.lib(KERNEL32.dll) : fatal error LNK1103: 调试信息损坏;请重新编译模块 [C:\Users\17904\Desktop\voiceChat\test\build\test_addon.vcxproj]
gyp ERR! build error 
gyp ERR! stack Error: `C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.<anonymous> (C:\Users\17904\AppData\Roaming\npm\node_modules\node-gyp\lib\build.js:209:23)
gyp ERR! stack at ChildProcess.emit (node:events:517:28)
gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:292:12)
gyp ERR! System Windows_NT 10.0.19045
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\17904\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "build"
gyp ERR! cwd C:\Users\17904\Desktop\voiceChat\test
gyp ERR! node -v v18.18.0
gyp ERR! node-gyp -v v10.1.0
gyp ERR! not ok
  • Node Version: v18.18.0
  • Platform:
    OS Name: Microsoft Windows 10 专业版
    OS Version: 10.0.19045 暂缺 Build 19045
    OS Type: x64-based PC
  • Compiler:
    用于 .NET Framework 的 Microsoft (R) 生成引擎版本 16.11.2+f32259642
    版权所有(C) Microsoft Corporation。保留所有权利。

16.11.2.50704

  • Module:

Rebuild the Node Modules, If everything else fails, you can try deleting the node_modules directory and reinstalling everything:

rm -rf node_modules
npm install
node-gyp rebuild