node-tree-sitter icon indicating copy to clipboard operation
node-tree-sitter copied to clipboard

Get NODE_MODULE_VERSION error when importing and using tree-sitter-javascript

Open TsukimiRini opened this issue 3 years ago • 1 comments

My nodeJS version is 14.17.0, using yarn v1.22.10 as the package manager. My OS is macOS Big Sur 11.2.3.

When I add tree-sitter and tree-sitter-javascript to my vscode extension development project, all appears to be well. But when I try some basic usage of tree-sitter, the error occurs:

Activating extension 'xxx' failed: The module '/path/to/project/node_modules/tree-sitter/build/Release/tree_sitter_runtime_binding.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 83. This version of Node.js requires
NODE_MODULE_VERSION 87. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`)..

All i have done is like:

import * as TreeSitter from 'tree-sitter'
const JavaScript = require('tree-sitter-javascript')
const treeSitter = new TreeSitter()
treeSitter.setLanguage(JavaScript)

TsukimiRini avatar May 29 '21 11:05 TsukimiRini

It looks like you have the same problem #86, try to follow instructions from the official Electron documentation: https://www.electronjs.org/docs/tutorial/using-native-node-modules

ahlinc avatar May 29 '21 19:05 ahlinc