Skip to content

Instantly share code, notes, and snippets.

@redice
Last active October 28, 2015 14:44
Show Gist options
  • Save redice/a4461b655eac1bcc5a2a to your computer and use it in GitHub Desktop.
Save redice/a4461b655eac1bcc5a2a to your computer and use it in GitHub Desktop.
failed node-java and node-jmx in node v4.2.1

I encountered node v4.2.1 can't run node-java and node-jmx

Error message

$ npm install jmx
> java@0.5.5 install /Users/redice/apache/git.repository/myprojects/learning.area/jmx/node_modules/jmx/node_modules/java
> node-gyp rebuild

  CXX(target) Release/obj.target/nodejavabridge_bindings/src/java.o
In file included from ../src/java.cpp:1:
In file included from ../src/java.h:9:
In file included from ../../nan/nan.h:80:
In file included from ../../nan/nan_new.h:190:
../../nan/nan_implementation_12_inl.h:181:66: error: too many arguments to function call, expected at most 2, have 4
  return v8::Signature::New(v8::Isolate::GetCurrent(), receiver, argc, argv);
         ~~~~~~~~~~~~~~~~~~                                      ^~~~~~~~~~
/Users/redice/.node-gyp/4.2.1/include/node/v8.h:4675:3: note: 'New' declared here
  static Local<Signature> New(
  ^
In file included from ../src/java.cpp:1:
In file included from ../src/java.h:9:
../../nan/nan.h:171:25: error: redefinition of '_NanEnsureLocal'
NAN_INLINE v8::Local<T> _NanEnsureLocal(v8::Local<T> val) {
                        ^
../../nan/nan.h:166:25: note: previous definition is here
NAN_INLINE v8::Local<T> _NanEnsureLocal(v8::Handle<T> val) {
                        ^
../../nan/nan.h:317:12: error: no matching function for call to '_NanEnsureLocal'
    return NanEscapeScope(NanNew(v8::Undefined(v8::Isolate::GetCurrent())));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../nan/nan.h:303:43: note: expanded from macro 'NanEscapeScope'
# define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))
                                          ^~~~~~~~~~~~~~~
../../nan/nan.h:171:25: note: candidate template ignored: substitution failure [with T = v8::Primitive]
NAN_INLINE v8::Local<T> _NanEnsureLocal(v8::Local<T> val) {
                        ^
../../nan/nan.h:322:12: error: no matching function for call to '_NanEnsureLocal'
    return NanEscapeScope(NanNew(v8::Null(v8::Isolate::GetCurrent())));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../nan/nan.h:303:43: note: expanded from macro 'NanEscapeScope'
# define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))
                                          ^~~~~~~~~~~~~~~
../../nan/nan.h:171:25: note: candidate template ignored: substitution failure [with T = v8::Primitive]
NAN_INLINE v8::Local<T> _NanEnsureLocal(v8::Local<T> val) {
                        ^
../../nan/nan.h:327:12: error: no matching function for call to '_NanEnsureLocal'
    return NanEscapeScope(NanNew(v8::True(v8::Isolate::GetCurrent())));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../nan/nan.h:303:43: note: expanded from macro 'NanEscapeScope'
# define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))
                                          ^~~~~~~~~~~~~~~
../../nan/nan.h:171:25: note: candidate template ignored: substitution failure [with T = v8::Boolean]
NAN_INLINE v8::Local<T> _NanEnsureLocal(v8::Local<T> val) {
                        ^
../../nan/nan.h:332:12: error: no matching function for call to '_NanEnsureLocal'
    return NanEscapeScope(NanNew(v8::False(v8::Isolate::GetCurrent())));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../nan/nan.h:303:43: note: expanded from macro 'NanEscapeScope'
# define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))
                                          ^~~~~~~~~~~~~~~
../../nan/nan.h:171:25: note: candidate template ignored: substitution failure [with T = v8::Boolean]
NAN_INLINE v8::Local<T> _NanEnsureLocal(v8::Local<T> val) {
                        ^
../../nan/nan.h:564:13: error: no member named 'smalloc' in namespace 'node'
    , node::smalloc::FreeCallback callback
      ~~~~~~^
../../nan/nan.h:575:12: error: no matching function for call to 'New'
    return node::Buffer::New(v8::Isolate::GetCurrent(), data, size);
           ^~~~~~~~~~~~~~~~~
/Users/redice/.node-gyp/4.2.1/include/node/node_buffer.h:31:40: note: candidate function not viable: no known conversion from 'uint32_t' (aka 'unsigned int') to 'enum encoding' for
      3rd argument
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                       ^
/Users/redice/.node-gyp/4.2.1/include/node/node_buffer.h:43:40: note: candidate function not viable: 2nd argument ('const char *') would lose const qualifier
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                       ^
/Users/redice/.node-gyp/4.2.1/include/node/node_buffer.h:28:40: note: candidate function not viable: requires 2 arguments, but 3 were provided
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate, size_t length);
                                       ^
/Users/redice/.node-gyp/4.2.1/include/node/node_buffer.h:36:40: note: candidate function not viable: requires 5 arguments, but 3 were provided
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                       ^
In file included from ../src/java.cpp:1:
In file included from ../src/java.h:9:
../../nan/nan.h:579:12: error: no viable conversion from 'v8::MaybeLocal<v8::Object>' to 'v8::Local<v8::Object>'
    return node::Buffer::New(v8::Isolate::GetCurrent(), size);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/redice/.node-gyp/4.2.1/include/node/v8.h:210:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'v8::MaybeLocal<v8::Object>'
      to 'const v8::Local<v8::Object> &' for 1st argument
class Local {
      ^
/Users/redice/.node-gyp/4.2.1/include/node/v8.h:210:7: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'v8::MaybeLocal<v8::Object>'
      to 'v8::Local<v8::Object> &&' for 1st argument
class Local {
      ^
/Users/redice/.node-gyp/4.2.1/include/node/v8.h:214:13: note: candidate template ignored: could not match 'Local' against 'MaybeLocal'
  V8_INLINE Local(Local<S> that)
            ^
/Users/redice/.node-gyp/4.2.1/include/node/v8.h:326:13: note: candidate template ignored: could not match 'S *' against 'v8::MaybeLocal<v8::Object>'
  V8_INLINE Local(S* that)
            ^
In file included from ../src/java.cpp:1:
In file included from ../src/java.h:9:
../../nan/nan.h:586:26: error: no member named 'Use' in namespace 'node::Buffer'
    return node::Buffer::Use(v8::Isolate::GetCurrent(), data, size);
           ~~~~~~~~~~~~~~^
../../nan/nan.h:1403:12: error: no matching function for call to '_NanEnsureLocal'
    return NanEscapeScope(NanNew(handle)->Get(kCallbackIndex)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../nan/nan.h:303:43: note: expanded from macro 'NanEscapeScope'
# define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))
                                          ^~~~~~~~~~~~~~~
../../nan/nan.h:171:25: note: candidate template ignored: substitution failure [with T = v8::Function]
NAN_INLINE v8::Local<T> _NanEnsureLocal(v8::Local<T> val) {
                        ^
../../nan/nan.h:1452:12: error: no matching function for call to '_NanEnsureLocal'
    return NanEscapeScope(node::MakeCallback(
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../nan/nan.h:303:43: note: expanded from macro 'NanEscapeScope'
# define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))
                                          ^~~~~~~~~~~~~~~
../../nan/nan.h:171:25: note: candidate template ignored: substitution failure [with T = v8::Value]
NAN_INLINE v8::Local<T> _NanEnsureLocal(v8::Local<T> val) {
                        ^
../../nan/nan.h:1522:12: error: no matching function for call to '_NanEnsureLocal'
    return NanEscapeScope(handle->Get(NanNew(key)).As<v8::Object>());
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../nan/nan.h:303:43: note: expanded from macro 'NanEscapeScope'
# define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))
                                          ^~~~~~~~~~~~~~~
../../nan/nan.h:171:25: note: candidate template ignored: substitution failure [with T = v8::Object]
NAN_INLINE v8::Local<T> _NanEnsureLocal(v8::Local<T> val) {
                        ^
13 errors generated.
make: *** [Release/obj.target/nodejavabridge_bindings/src/java.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/redice/.nvm/versions/node/v4.2.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:270:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Darwin 14.5.0
gyp ERR! command "/Users/redice/.nvm/versions/node/v4.2.1/bin/node" "/Users/redice/.nvm/versions/node/v4.2.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/redice/apache/git.repository/myprojects/learning.area/jmx/node_modules/jmx/node_modules/java
gyp ERR! node -v v4.2.1
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
jmx_sample@1.0.0 /Users/redice/apache/git.repository/myprojects/learning.area/jmx
└── (empty)

npm WARN EPACKAGEJSON jmx_sample@1.0.0 No description
npm WARN EPACKAGEJSON jmx_sample@1.0.0 No repository field.
npm ERR! Darwin 14.5.0
npm ERR! argv "/Users/redice/.nvm/versions/node/v4.2.1/bin/node" "/Users/redice/.nvm/versions/node/v4.2.1/bin/npm" "install" "jmx"
npm ERR! node v4.2.1
npm ERR! npm  v3.3.10
npm ERR! code ELIFECYCLE

npm ERR! java@0.5.5 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the java@0.5.5 install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the java package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls java
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/redice/apache/git.repository/myprojects/learning.area/jmx/npm-debug.log
npm ERR! code 1

My environment is below

  • OS: Mac OS X 10.10 Yosemite
  • Node: v4.2.1

I failed to use npm to install node-java and node-jmx.

But, it's a way to fix it in my experiment.

  1. download node-java and node-jmx source code from Github.

  2. update the following the dependencies.

  1. use npm install by source codes.

After the patch, node-java and node-jmx both work well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment