Search code examples
node.jselectronv8node-gyp

Utf8Value error C2661: No overloaded function takes 2 arguments


I created a node module, with a native code. I use v8::String::Utf8Value::Utf8Value, and in the documentation it's writen it needs two parameters.

So I use

Isolate * isolate = info.GetIsolate();
Local<Context> context = isolate->GetCurrentContext();
Local<Array> array = Local<Array>::Cast(info[0]);
MaybeLocal<Value> maybeIndex = array->Get(context, 0);
Local<Value> index = maybeIndex.ToLocalChecked();

// This is the important line
String::Utf8Value path(isolate, index);

When I'm developing the module, no problem, npm install build it, travis as well.

But when I want to use this module in an application (electron), when I run .\node_modules\.bin\electron-rebuild.cmd to build my module, it fails and displays error C2661: No overloaded function takes 2 arguments for v8::String::Utf8Value::Utf8Value.

I don't know what I miss, so it would be really great if someone know what happened to me.

You can see the code on Github, and particulary the last commit here

Infos: - The module is Windows only - I used Node 12, and tried to upgrade it to 13, no change - node-gyp is version 5.0.5 when building my module, version 6.0.1 when building through electron-rebuild


Solution

  • What's the Electron version you're trying to build for? Ancient V8 versions didn't have the two-argument version of Utf8Value, but ever since the 6.2 branch (summer 2017) it has existed. So if your Electron-based app is very old, then that would explain it and updating it should fix it.