VSCode-Extensions | A-to-Z List of Useful JavaScript VSCode Extensions
kandi X-RAY | VSCode-Extensions Summary
kandi X-RAY | VSCode-Extensions Summary
A-to-Z List of Useful JavaScript VSCode Extensions
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of VSCode-Extensions
VSCode-Extensions Key Features
VSCode-Extensions Examples and Code Snippets
Community Discussions
Trending Discussions on VSCode-Extensions
QUESTION
I'm trying to use node's tree-sitter package in my vscode extension, but I get the following error:
Activating extension 'extension name' failed: The module '.../node_modules/tree-sitter/build/Release/tree_sitter_runtime_binding.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 93. This version of Node.js requires NODE_MODULE_VERSION 89. Please try re-compiling or re-installing the module (for instance, using
npm rebuild
ornpm install
)..
From what I understand, the NODE_MODULE_VERSION is the version of node's ABI. However, I couldn't even find a release of node that has NODE_MODULE_VERSION 89 in the official website.
What I've tried:- Deleting the node_modules folder and reinstalling the packages.
- Running
npm rebuild tree-sitter --update-binary
from the top directory. - Rebuilding the tree-sitter package with
node-gyp rebuild
andnode-gyp rebuild --target=(my node version)
from thenode_modules/tree-sitter
directory. - Switching node versions using nvm.
None of that helped. I understand from here that changing node versions won't help, as I confirmed when I tried
console.log(process.version); // v14.16.0
console.log(process.versions.modules); // 89
This gave the same output no matter which node version I used. I also tried rebuilding the tree-sitter package using that node version node-gyp rebuild --target=14.16.0
, but I get the same error, however this time it says the module was compiled using NODE_MODULE_VERSION 83, which is consistent with what node's site says.
How do I resolve this error? Any help is appreciated.
...ANSWER
Answered 2022-Mar-23 at 22:45As I suspected, the version of node ABI used by vscode extensions is the ABI version used by vscode's internal electron. According to this source
Native Node.js modules are supported by Electron, but since Electron has a different application binary interface (ABI) from a given Node.js binary (due to differences such as using Chromium's BoringSSL instead of OpenSSL), the native modules you use will need to be recompiled for Electron...
This explains why I couldn't find NODE_MODULE_VERSION 89 in node's site.
Next, I checked what version of electron my build of vscode uses. To do this, I simply checked the package.json that came with vscode (/usr/lib/code/package.json
on linux, I guess that it is inside the folder vscode is installed on on windows).
Next, following the instructions from electron's site, rebuild the module using the package electron-rebuild
. To specify a target version, simply run
./node_modules/.bin/electron-rebuild -v [version]
However, I have no source for this but it seems that tree-sitter does not currently support newer versions of electron, so the build fails. This seems to be because of a change in V8's API (according to this).
The author linked his solution here. I copied his changes and the build succeeded.
Note that I had to replace the existing node addon with the newly built one.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install VSCode-Extensions
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page