Issue with Couchbase node.js client and VS Code Extension Debugger

I’m unable to get the Couchbase node client to work when trying to debug VS Code extensions following the steps here Your First Extension | Visual Studio Code Extension API. The only change I’ve made is that I’ve installed the node.js client using npm and as soon as I include the import for Couchbase (const couchbase = require(“couchbase”); ) I get the following error

Activating extension ‘test.vscode-couchbase-js’ failed: The module ‘/Users/Projects/VSCode/vscode-couchbase-js/node_modules/couchbase/build/Release/couchbase_impl.node’
was compiled against a different Node.js version using
NODE_MODULE_VERSION 83. This version of Node.js requires
NODE_MODULE_VERSION 85. Please try re-compiling or re-installing
the module (for instance, using npm rebuild or npm install)

I get a similar error when I try to debug the typescript version of the extension as well when including the import (import * as couchbase from ‘couchbase’; )

Activating extension ‘test.vscode-couchbase-ts’ failed: Could not locate the bindings file. Tried:
→ /Users/Projects/vscode-couchbase-ts/build/couchbase_impl.node
→ /Users/Projects/vscode-couchbase-ts/build/Debug/couchbase_impl.node
→ /Users/Projects/vscode-couchbase-ts/build/Release/couchbase_impl.node
→ /Users/Projects/vscode-couchbase-ts/out/Debug/couchbase_impl.node
→ /Users/Projects/vscode-couchbase-ts/Debug/couchbase_impl.node
→ /Users/Projects/vscode-couchbase-ts/out/Release/couchbase_impl.node
→ /Users/Projects/vscode-couchbase-ts/Release/couchbase_impl.node
→ /Users/Projects/vscode-couchbase-ts/build/default/couchbase_impl.node
→ /Users/Projects/vscode-couchbase-ts/compiled/12.18.3/darwin/x64/couchbase_impl.node
→ /Users/Projects/vscode-couchbase-ts/addon-build/debug/install-root/couchbase_impl.node
→ /Users/vscode-couchbase-ts/addon-build/default/install-root/couchbase_impl.node
→ /Users/Projects/vscode-couchbase-ts/lib/binding/node-v85-darwin-x64/couchbase_impl.node.

I’ve tried deleting the node_modules folders and running npm install as well as npm rebuild but continue getting the same error.

image

Hey @brett19 looking for your input on this.

Is this by chance on Windows?

The Couchbase Node.JS SDK uses some native code, and a quick search turned up this documented as the error you might get from Electron, as it uses a different ABI. We use node-gyp to try to prepackage the binary dependencies.

There is an Electron doc on Using Native Node Modules. Can you try what you see there?

Hey @ingenthr I’m trying to run this on a Mac. I went through the steps here and was able to rebuild successfully. However, I still get the same errors when trying to debug the extension.

You can see the console output here > ./node_modules/.bin/electron-rebuild ⠋ Building module: couchba - Pastebin.com

Hey @codefish75 ,

It sounds like the Node.js version being used by your vscode does not match the Node.js version used at the terminal. The error your seeing indicates that the extension was installed using a Node.js version older than the one your debugging with.

Cheers, Brett

@brett19 The Node.js versions are the same at both places, using version 12.18.3. This issue only comes up when I try importing the Couchbase Node.js SDK. It runs fine with other node packages I’ve installed and imported.

Hey @codefish75 ,

It’s worth pointing out that the Node.js version used within VSCode is not necessarily the same one that VSCode uses when launching your application. You can use the terminal in vscode to run node --version, and then run the same command in your terminal outside of VSCode to see which one your OS terminal is using. It might be helpful to show that the module was installed with ABI 83 which is Node.js v14, but is being run with ABI 85, which is Electron v11.

Cheers, Brett

Hey @brett19,

I don’t believe that is the issue. I’ve made sure that the node versions match up.

Terminal Outside VSCode

node -v

v12.18.3

Terminal From VS Code

vscode % node -v

v12.18.3

These are my VS Code configs

Visual Studio Code

I’ve tried using different versions of node making sure they all match but still run into the issue.

Again, it only happens when using the Couchbase SDK. It doesn’t happen with non Couchbase SDKs.

Thanks

Hey @codefish75 ,

It seems like this is actually a known issue with debugging from VSCode. I’ve included a link below, but the gist of the problem is that the Couchbase Node.js library uses native bindings for performance reasons, unfortunately this means that you’re Node.js installation must match between npm install and running the application for ABI compatibility reasons. Due to the fact that VSCode’s debugger runs using the built-in electron version, you will need to do a special build of the SDK, you can find instructions how to do that at the link as well.

Cheers, Brett