-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Node module version mismatch when integrating tree-sitter with VS Code extension #169
Comments
I've since had some success, in abandoning the |
IIUC, if the performance is not an issue, going the I understand that this is a route that seems to have worked out for some cases for VSCode extensions. |
There are few steps required to do what you want. |
The latest version is Node-API based which should work in electron/VS Code much more easily, but the grammars still need to also be regenerated to use Node-API. |
I'm in the process of integrating a tree-sitter grammar/parser into an LSP-based VS Code extension. This grammar was previously demonstrated in a browser environment using WASM bindings. My current goal is to facilitate syntax highlighting through our parser on the server side of this extension. But first, I need to successfully import the tree-sitter package.
Here are some technical details that might be relevant:
-- No explicit Electron version in the root project.json, but it specifies "engines": { "vscode": "^1.83.1" }.
-- LSP server dependencies include:
---
"@webassemblyjs/wasm-edit": "1.11.6"
---
"tree-sitter": "0.20.6"
When I include
const Parser = require("tree-sitter");
in the LSP'sserver.ts
and execute the extension, I face an error indicating a module version mismatch. The error suggests the tree-sitter module was compiled with a different Node.js version.I'm not well-acquainted with these
NODE_MODULE_VERSION
tags, but it seems they map to distinct Node versions, as seen in this reference table: https://nodejs.org/en/download/releasesI've come across several discussions suggesting the use of
electron-rebuild
to address this issue. Subsequently, I've incorporated "@electron/rebuild": "^3.3.0", into theproject.json
of the extension server as adevDependency
. On executing./node_modules/.bin/electron-rebuild -v 25.8.4
, it swiftly completes, indicating a successful rebuild with a "✔ Rebuild Complete" message.However, when I attempt to launch the extension once more, I'm presented with a slightly different error:
Heading in the wrong direction, it seems.
Separately, I've taken some advice from another thread to clone and build
node-tree-sitter
locally from source, and use that rather than the released bits. No luck there - after cloning, annpm i
fails onNo rule to make target 'Release/obj.target/tree_sitter/vendor/tree-sitter/lib/src/lib.o', needed by 'Release/obj.target/tree_sitter.a'
.I've extensively scoured related issues to find a solution but to no avail. I hope this issue sheds some light on my specific problem. I apologize if this appears repetitive and thank you in advance for your assistance.
The text was updated successfully, but these errors were encountered: