tree-sitter / node-tree-sitter

Node.js bindings for tree-sitter
https://www.npmjs.com/package/tree-sitter
MIT License
649 stars 114 forks source link

npm installation fails #112

Closed uliw closed 2 years ago

uliw commented 2 years ago

I've installed treesitter with make and make install, but the subsequent call to ` npm install tree-sitter results in the below error. Did I overlook the obvious? Thanks!

gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! In file included from ../src/binding.cc:1:
npm ERR! /root/.cache/node-gyp/17.7.1/include/node/node.h:848:7: warning: cast between incompatible function types from ‘void (*)(v8::Local<v8::Object>)’ to ‘node::addon_register_func’ {aka ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)’} [-Wcast-function-type]
npm ERR!   848 |       (node::addon_register_func) (regfunc),                          \
npm ERR!       |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! /root/.cache/node-gyp/17.7.1/include/node/node.h:882:3: note: in expansion of macro ‘NODE_MODULE_X’
npm ERR!   882 |   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
npm ERR!       |   ^~~~~~~~~~~~~
npm ERR! ../src/binding.cc:25:1: note: in expansion of macro ‘NODE_MODULE’
npm ERR!    25 | NODE_MODULE(tree_sitter_runtime_binding, InitAll)
npm ERR!       | ^~~~~~~~~~~
npm ERR! ../src/conversions.cc: In function ‘void node_tree_sitter::InitConversions(v8::Local<v8::Object>)’:
npm ERR! ../src/conversions.cc:31:51: error: no matching function for call to ‘v8::ArrayBuffer::New(v8::Isolate*, uint32_t*&, long unsigned int)’
npm ERR!    31 |   auto js_point_transfer_buffer = ArrayBuffer::New(Isolate::GetCurrent(), point_transfer_buffer, 2 * sizeof(uint32_t));
npm ERR!       |                                   ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! In file included from /root/.cache/node-gyp/17.7.1/include/node/v8.h:25,
npm ERR!                  from /root/.cache/node-gyp/17.7.1/include/node/node.h:63,
npm ERR!                  from ../../nan/nan.h:60,
npm ERR!                  from ../src/./node.h:4,
npm ERR!                  from ../src/conversions.cc:1:
npm ERR! /root/.cache/node-gyp/17.7.1/include/node/v8-array-buffer.h:198:29: note: candidate: ‘static v8::Local<v8::ArrayBuffer> v8::ArrayBuffer::New(v8::Isolate*, size_t)’
npm ERR!   198 |   static Local<ArrayBuffer> New(Isolate* isolate, size_t byte_length);
npm ERR!       |                             ^~~
npm ERR! /root/.cache/node-gyp/17.7.1/include/node/v8-array-buffer.h:198:29: note:   candidate expects 2 arguments, 3 provided
npm ERR! /root/.cache/node-gyp/17.7.1/include/node/v8-array-buffer.h:212:29: note: candidate: ‘static v8::Local<v8::ArrayBuffer> v8::ArrayBuffer::New(v8::Isolate*, std::shared_ptr<v8::BackingStore>)’
npm ERR!   212 |   static Local<ArrayBuffer> New(Isolate* isolate,
npm ERR!       |                             ^~~
npm ERR! /root/.cache/node-gyp/17.7.1/include/node/v8-array-buffer.h:212:29: note:   candidate expects 2 arguments, 3 provided
npm ERR! make: *** [tree_sitter_runtime_binding.target.mk:127: Release/obj.target/tree_sitter_runtime_binding/src/conversions.o] Error 1
npm ERR! gyp ERR! build error 
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/root/node_modules/node-gyp/lib/build.js:201:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:527:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Linux 5.19.2-1-default
npm ERR! gyp ERR! command "/usr/bin/node17" "/root/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /root/node_modules/tree-sitter
npm ERR! gyp ERR! node -v v17.7.1
npm ERR! gyp ERR! node-gyp -v v9.1.0
npm ERR! gyp ERR! not ok
uliw commented 2 years ago

this is solved by following https://stackoverflow.com/questions/67698463/trying-to-npm-install-getting-node-gyp-rebuild-errors