How to run vscode extension which depends on native module

Viewed 248

I'm working on vscode extension and one of the package: node-java which my app depends on is a native module. This library is used to call java code from typescript or javascript. I already used this package in a plain node.js project and it was working as I expected. However, when I start my vscode app, I got the errors:

Activating extension 'undefined_publisher.extension-example' failed: The module '$HOME/typescript-tutorial/extension-example/node_modules/java/build/Release/nodejavabridge_bindings.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 or npm install)

My node version: v16.13.1 and vscode version: 1.63.0.

I know vscode extension is electron app and I followed this step https://www.electronjs.org/docs/latest/tutorial/using-native-node-modules to install native module on my app. What I did is:

  1. Delete node-module folder and package-lock.json
  2. install electron using npm: npm install --save-dev electron
  3. Install electron rebuild: npm install --save-dev electron-rebuild
  4. Run npm install
  5. run ./node-module/.bin/electron-rebuild

Everything went well without any errors.However, when I start my vscode extension again, the error does no go away. My question here is: Does anyone know or try vscode extension which depends on native module and if so, could you please help me to install it?

0 Answers
Related