hello world上的node-gyp构建错误

时间:2015-04-09 09:13:58

标签: node.js node-gyp

我正在尝试编译node hello world addon并在我打电话时 node-gyp configure build它会产生多个错误。

../binding.cc:6:19: error: unknown type name 'FunctionCallbackInfo'
    void Method(const FunctionCallbackInfo<Value>& args) {
                      ^
../binding.cc:6:39: error: expected ')'
    void Method(const FunctionCallbackInfo<Value>& args) {
                                          ^
../binding.cc:6:12: note: to match this '('
    void Method(const FunctionCallbackInfo<Value>& args) {
               ^
../binding.cc:8:15: error: no matching constructor for initialization of 'v8::HandleScope'
      HandleScope scope(isolate);
                  ^     ~~~~~~~
/***/***/.node-gyp/0.10.36/deps/v8/include/v8.h:473:3: note: candidate constructor not viable: no known conversion from 'v8::Isolate *' to 'const v8::HandleScope' for 1st
          argument
      HandleScope(const HandleScope&);
      ^
/****/***/.node-gyp/0.10.36/deps/v8/include/v8.h:448:3: note: candidate constructor not viable: requires 0 arguments, but 1 was provided
      HandleScope();
      ^
../binding.cc:9:3: error: use of undeclared identifier 'args'
      args.GetReturnValue().Set(String::NewFromUtf8(isolate, "world"));
      ^
../binding.cc:9:37: error: no member named 'NewFromUtf8' in 'v8::String'
      args.GetReturnValue().Set(String::NewFromUtf8(isolate, "world"));

可能是什么问题?

1 个答案:

答案 0 :(得分:1)

问题是该示例假设您正在运行节点0.12,但您正在运行节点0.10(看起来为0.10.36)。在节点0.12中,插件的结构方式发生了很大的(向后不兼容的)变化。

以下是与0.10兼容的版本:https://github.com/joyent/node/blob/aa35564ca1c9f3854bc5f7983f2f00cb51f67ffe/test/addons/hello-world/binding.cc

一个很棒的程序包将处理Node版本之间的许多差异nan