升级到Node 0.12 stable 发现memwatch用不了
发布于 9 年前 作者 hackeridear 8670 次浏览 最后一次编辑是 8 年前 来自 问答

升级到Node 0.12 stable 发现memwatch安装报错了,具体错误如下:

> memwatch@0.2.2 install /Users/hackeridear/WebstormProjects/ins-comet-platform-process/node_modules/memwatch
> node-gyp rebuild

child_process: customFds option is deprecated, use stdio instead.
  CXX(target) Release/obj.target/memwatch/src/heapdiff.o
In file included from ../src/heapdiff.cc:5:
../src/heapdiff.hh:14:35: error: expected class name
    class HeapDiff : public node::ObjectWrap
                                  ^
../src/heapdiff.hh:19:49: error: no type named 'Arguments' in namespace 'v8'; did you mean 'v8::internal::Arguments'?
        static v8::Handle<v8::Value> New( const v8::Arguments& args );
                                                ^~~~~~~~~~~~~
                                                v8::internal::Arguments
/Users/hackeridear/.node-gyp/0.12.0/deps/v8/include/v8.h:127:7: note: 'v8::internal::Arguments' declared here
class Arguments;
      ^
In file included from ../src/heapdiff.cc:5:
../src/heapdiff.hh:20:49: error: no type named 'Arguments' in namespace 'v8'; did you mean 'v8::internal::Arguments'?
        static v8::Handle<v8::Value> End( const v8::Arguments& args );
                                                ^~~~~~~~~~~~~
                                                v8::internal::Arguments
/Users/hackeridear/.node-gyp/0.12.0/deps/v8/include/v8.h:127:7: note: 'v8::internal::Arguments' declared here
class Arguments;
      ^
../src/heapdiff.cc:30:34: error: member initializer 'ObjectWrap' does not name a non-static data member or base class
heapdiff::HeapDiff::HeapDiff() : ObjectWrap(), before(NULL), after(NULL),
                                 ^~~~~~~~~~~~
../src/heapdiff.cc:51:21: error: calling a protected constructor of class 'v8::HandleScope'
    v8::HandleScope scope;
                    ^
/Users/hackeridear/.node-gyp/0.12.0/deps/v8/include/v8.h:816:13: note: declared protected here
  V8_INLINE HandleScope() {}
            ^
../src/heapdiff.cc:52:67: error: cannot initialize a parameter of type 'v8::Isolate *' with an lvalue of type 'v8::Handle<v8::Value> (const v8::internal::Arguments &)'
    v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(New);
                                                                  ^~~
/Users/hackeridear/.node-gyp/0.12.0/deps/v8/include/v8.h:3456:16: note: passing argument to parameter 'isolate' here
      Isolate* isolate,
               ^
../src/heapdiff.cc:54:29: error: no member named 'NewSymbol' in 'v8::String'
    t->SetClassName(String::NewSymbol("HeapDiff"));
                    ~~~~~~~~^
../src/heapdiff.cc:56:41: error: cannot initialize a parameter of type 'v8::FunctionCallback' (aka 'void (*)(const FunctionCallbackInfo<v8::Value> &)') with an lvalue of
      type 'v8::Handle<v8::Value> (const v8::internal::Arguments &)': type mismatch at 1st parameter ('const FunctionCallbackInfo<v8::Value> &' vs
      'const v8::internal::Arguments &')
    NODE_SET_PROTOTYPE_METHOD(t, "end", End);
                                        ^~~
/Users/hackeridear/.node-gyp/0.12.0/src/node.h:246:60: note: passing argument to parameter 'callback' here
                                      v8::FunctionCallback callback) {
                                                           ^
../src/heapdiff.cc:58:29: error: no member named 'NewSymbol' in 'v8::String'
    target->Set(v8::String::NewSymbol( "HeapDiff"), t->GetFunction());
                ~~~~~~~~~~~~^
../src/heapdiff.cc:62:32: error: no type named 'Arguments' in namespace 'v8'; did you mean 'v8::internal::Arguments'?
heapdiff::HeapDiff::New (const v8::Arguments& args)
                               ^~~~~~~~~~~~~
                               v8::internal::Arguments
/Users/hackeridear/.node-gyp/0.12.0/deps/v8/include/v8.h:127:7: note: 'v8::internal::Arguments' declared here
class Arguments;
      ^
../src/heapdiff.cc:67:14: error: member access into incomplete type 'const v8::internal::Arguments'
    if (!args.IsConstructCall()) {
             ^
/Users/hackeridear/.node-gyp/0.12.0/deps/v8/include/v8.h:127:7: note: forward declaration of 'v8::internal::Arguments'
class Arguments;
      ^
../src/heapdiff.cc:70:17: error: no member named 'New' in 'v8::String'; did you mean simply 'New'?
                String::New("Use the new operator to create instances of this object.")));
                ^~~~~~~~~~~
                New
../src/heapdiff.cc:62:21: note: 'New' declared here
heapdiff::HeapDiff::New (const v8::Arguments& args)
                    ^
../src/heapdiff.cc:70:29: error: reference to type 'const v8::internal::Arguments' could not bind to an lvalue of type 'const char [57]'
                String::New("Use the new operator to create instances of this object.")));
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/heapdiff.cc:62:47: note: passing argument to parameter 'args' here
heapdiff::HeapDiff::New (const v8::Arguments& args)
                                              ^
../src/heapdiff.cc:73:21: error: calling a protected constructor of class 'v8::HandleScope'
    v8::HandleScope scope;
                    ^
/Users/hackeridear/.node-gyp/0.12.0/deps/v8/include/v8.h:816:13: note: declared protected here
  V8_INLINE HandleScope() {}
            ^
../src/heapdiff.cc:77:11: error: no member named 'Wrap' in 'heapdiff::HeapDiff'
    self->Wrap(args.This());
    ~~~~  ^
../src/heapdiff.cc:77:20: error: member access into incomplete type 'const v8::internal::Arguments'
    self->Wrap(args.This());
                   ^
/Users/hackeridear/.node-gyp/0.12.0/deps/v8/include/v8.h:127:7: note: forward declaration of 'v8::internal::Arguments'
class Arguments;
      ^
../src/heapdiff.cc:82:38: error: no member named 'TakeSnapshot' in 'v8::HeapProfiler'
    self->before = v8::HeapProfiler::TakeSnapshot(v8::String::New(""));
                   ~~~~~~~~~~~~~~~~~~^
../src/heapdiff.cc:82:51: error: no member named 'New' in 'v8::String'; did you mean simply 'New'?
    self->before = v8::HeapProfiler::TakeSnapshot(v8::String::New(""));
                                                  ^~~~~~~~~~~~~~~
                                                  New
../src/heapdiff.cc:62:21: note: 'New' declared here
heapdiff::HeapDiff::New (const v8::Arguments& args)
                    ^
../src/heapdiff.cc:82:67: error: reference to type 'const v8::internal::Arguments' could not bind to an lvalue of type 'const char [1]'
    self->before = v8::HeapProfiler::TakeSnapshot(v8::String::New(""));
                                                                  ^~
../src/heapdiff.cc:62:47: note: passing argument to parameter 'args' here
heapdiff::HeapDiff::New (const v8::Arguments& args)
                                              ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [Release/obj.target/memwatch/src/heapdiff.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1067:12)
gyp ERR! System Darwin 13.4.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/hackeridear/WebstormProjects/ins-comet-platform-process/node_modules/memwatch
gyp ERR! node -v v0.12.0
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok 
npm ERR! Darwin 13.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v0.12.0
npm ERR! npm  v2.5.1
npm ERR! code ELIFECYCLE
\n```
6 回复

v0.10.33 安装没发现问题

@dayuoba 升级到0.11 之后都有问题

@hackeridear 重新升级下memwatch,或者用nan模块重写下才行

@zhangtao0x memwatch 的版本一直没更新

@hackeridear 那你看看nan模块,把memwatch里面的cc文件用nan的这种方式改写下,或者干脆换一个模块吧

尝试着修改了一下memwatch的代码,以支持0.11之后的版本,楼主可以试试看: npm install memwatch@git://github.com/crystaldust/node-memwatch.git#higher-than-v10

回到顶部