node-tree-sitter
node-tree-sitter copied to clipboard
cannot install on Node 18
$ brew install node
$ cd /tmp
$ mkdir tree-sitter-test
$ cd tree-sitter-test
$ npm init -y
$ npm install tree-sitter
npm ERR! code 1
npm ERR! path /private/tmp/node-test/node_modules/tree-sitter
npm ERR! command failed
npm ERR! command sh -c prebuild-install || node-gyp rebuild
npm ERR! CC(target) Release/obj.target/tree_sitter/vendor/tree-sitter/lib/src/lib.o
npm ERR! LIBTOOL-STATIC Release/tree_sitter.a
npm ERR! CXX(target) Release/obj.target/tree_sitter_runtime_binding/src/binding.o
npm ERR! CXX(target) Release/obj.target/tree_sitter_runtime_binding/src/conversions.o
npm ERR! prebuild-install WARN install No prebuilt binaries found (target=18.0.0 runtime=node arch=arm64 libc= platform=darwin)
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | darwin | arm64
npm ERR! gyp info find Python using Python version 3.9.12 found at "/opt/homebrew/opt/[email protected]/bin/python3.9"
npm ERR! gyp info spawn /opt/homebrew/opt/[email protected]/bin/python3.9
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/private/tmp/node-test/node_modules/tree-sitter/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/space/Library/Caches/node-gyp/18.0.0/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/Users/space/Library/Caches/node-gyp/18.0.0',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/Users/space/Library/Caches/node-gyp/18.0.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/private/tmp/node-test/node_modules/tree-sitter',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! In file included from ../src/binding.cc:3:
npm ERR! In file included from ../src/./language.h:4:
npm ERR! ../../nan/nan.h:2544:8: warning: 'SetAccessor' is deprecated: Do signature check in accessor [-Wdeprecated-declarations]
npm ERR! tpl->SetAccessor(
npm ERR! ^
npm ERR! /Users/space/Library/Caches/node-gyp/18.0.0/include/node/v8-template.h:837:3: note: 'SetAccessor' has been explicitly marked deprecated here
npm ERR! V8_DEPRECATED("Do signature check in accessor")
npm ERR! ^
npm ERR! /Users/space/Library/Caches/node-gyp/18.0.0/include/node/v8config.h:460:35: note: expanded from macro 'V8_DEPRECATED'
npm ERR! # define V8_DEPRECATED(message) [[deprecated(message)]]
npm ERR! ^
npm ERR! 1 warning generated.
npm ERR! In file included from ../src/conversions.cc:1:
npm ERR! In file included from ../src/./node.h:4:
npm ERR! ../../nan/nan.h:2544:8: warning: 'SetAccessor' is deprecated: Do signature check in accessor [-Wdeprecated-declarations]
npm ERR! tpl->SetAccessor(
npm ERR! ^
npm ERR! /Users/space/Library/Caches/node-gyp/18.0.0/include/node/v8-template.h:837:3: note: 'SetAccessor' has been explicitly marked deprecated here
npm ERR! V8_DEPRECATED("Do signature check in accessor")
npm ERR! ^
npm ERR! /Users/space/Library/Caches/node-gyp/18.0.0/include/node/v8config.h:460:35: note: expanded from macro 'V8_DEPRECATED'
npm ERR! # define V8_DEPRECATED(message) [[deprecated(message)]]
npm ERR! ^
npm ERR! ../src/conversions.cc:31:35: error: no matching function for call to 'New'
npm ERR! auto js_point_transfer_buffer = ArrayBuffer::New(Isolate::GetCurrent(), point_transfer_buffer, 2 * sizeof(uint32_t));
npm ERR! ^~~~~~~~~~~~~~~~
npm ERR! /Users/space/Library/Caches/node-gyp/18.0.0/include/node/v8-array-buffer.h:198:29: note: candidate function not viable: requires 2 arguments, but 3 were provided
npm ERR! static Local<ArrayBuffer> New(Isolate* isolate, size_t byte_length);
npm ERR! ^
npm ERR! /Users/space/Library/Caches/node-gyp/18.0.0/include/node/v8-array-buffer.h:212:29: note: candidate function not viable: requires 2 arguments, but 3 were provided
npm ERR! static Local<ArrayBuffer> New(Isolate* isolate,
npm ERR! ^
npm ERR! 1 warning and 1 error generated.
npm ERR! make: *** [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 (/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:527:28)
npm ERR! gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Darwin 21.4.0
npm ERR! gyp ERR! command "/opt/homebrew/Cellar/node/18.0.0/bin/node" "/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /private/tmp/node-test/node_modules/tree-sitter
npm ERR! gyp ERR! node -v v18.0.0
npm ERR! gyp ERR! node-gyp -v v9.0.0
npm ERR! gyp ERR! not ok
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/space/.npm/_logs/2022-04-28T05_30_29_464Z-debug-0.log
Any update on this?
Any update on this?
Or workaround 😄
Looks like this was fixed by 0.20.1
~$ cd /tmp
/tmp$ mkdir tree-sitter-test
/tmp$ cd tree-sitter-test
/tmp/tree-sitter-test$ npm init -y
Wrote to /private/tmp/tree-sitter-test/package.json:
{
"name": "tree-sitter-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
/tmp/tree-sitter-test$ npm install tree-sitter
added 59 packages, and audited 60 packages in 13s
6 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
/tmp/tree-sitter-test$ node --version
v18.11.0
/tmp/tree-sitter-test$ npm --version
8.19.2
Looks like this was fixed by 0.20.1
sadly not, am still getting error of
failed: The module '/xxx/node_modules/tree-sitter/build/Release/tree_sitter_runtime_binding.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 108. This version of Node.js requires
NODE_MODULE_VERSION 106. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`)..
there is no 106 check https://nodejs.org/en/download/releases/
@ctf0 I think you just need to do
rm -rf ./node_modules
# or
# rm -rf ./node_modules/tree-sitter
npm install
@ctf0 I think you just need to do
rm -rf ./node_modules # or # rm -rf ./node_modules/tree-sitter npm install
already did that 😔
What is your node --version and npm --version?
The 106 is saying that your Node is ABI version 106, which is weird because it doesn't exist in that table. Are you running on Electron version 19 (with Node 16)? because then your issue seems unrelated, you should open a different issue.
@verhovsky
node: v19.2.0
npm: 8.19.3
Are you running on Electron version 19 (with Node 16)?
am trying to use the pkg inside vscode extension
Version: 1.74.0-insider
Commit: 493a541735b84de36b628750ba716a430669cb7f
Date: 2022-12-02T05:22:22.871Z
Electron: 19.1.8
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Darwin arm64 21.6.0
Sandboxed: Yes
Were you able to solve this issue ?
@abhinavkamazon your issue (assuming it's the same as @ctf0's) is not the issue you're commenting on. As I said here, I think this package is installable on Node 18 now. Your issue is that you're using an old Node version (you're using Electron's Node, not the Node you're using to run your project).
You will need to ask/help maxbrunsfeld compile this project for your version, but this is unlikely because there are like 40 tree-sitter repositories (and they need to be released on both npm and Rust's crates.io) and I suppose he has better things to do than make 80 different releases or find someone that he trusts (I asked) to make releases.
Otherwise, you will have to upgrade your Electron version. In a week (February 7th), Electron 23 should be released and I think that will come with Node 18, so node-tree-sitter should work there, let us know if you try this.
You could try using an old version of node-tree-sitter by doing a binary search npm installing old versions to find the last supported version. Please let everyone on this issue know which version works if you do this.
You could git clone [email protected]:tree-sitter/node-tree-sitter.git into a different directory, compile the project yourself locally and add it as a file dependency in package.json like this:
{
...
"dependencies": {
"node-tree-sitter": "file:../node-tree-sitter",
...
}
}
in this example package.json, node-tree-sitter/ is cloned into the same directory as your project i.e.
- ~/some-directory/your-project
- ~/some-directory/node-tree-sitter
You could fork this repo, compile and publish your own package under a namespace. I do this with tree-sitter-bash because there hasn't been a new release since May 2021.