0
votes

I'm developing a VSCode extension which queries an Oracle database instance via oracledb npm

vscode-database extension was taken as a basis.

Node version installed is 8.9.4. Test script, which checks connection with Oracle works fine:

-> node -v
8.9.4
-> node connect.js
ok

But when I'm trying to debug the VSCode extension with the same connection script, I get error:

Activating extension bajdzis.vscode-database failed: NJS-045: cannot load the oracledb add-on binary for Node.js 7.9.0 (win32, x64)

The error says Node.js 7.9.0 is utilizing, not 8.9.4. I assume that 7.9.0 - is some internal Node instance which is used by VSCode debugger.

Is it possible make VSCode debugger to use Node version installed on a developer's machine, not the internal one?

1
Found similar question here: github.com/Microsoft/vscode/issues/18253 . Considering what they say, the answer to my question is "No": "VS Code runs extensions on the node version that is built into electron (on which VS Code is based). This cannot be changed." - Dmitry Taipov
Can you compile node-oracledb from source code? The installation instructions include the steps. - Christopher Jones
The thing is I can't because of the proxy issues at my office computer. And there is no official precompiled library of oracledb for Node 7.9.0 . But if to compile source is the easiest way to get oracledb to work with Node 7.9.0, I will go in this direction. Also have posted a comment here . Thank you! - Dmitry Taipov

1 Answers

0
votes

While it's not possible to make the VS Code debugger use a different version of Node.js, it is possible to compile native modules (like node-oracledb) for the target version of Node.js. Here are some details.

For VS Code 1.21.1 (which uses Electron 1.7.0), I did the following from a terminal in my extension directory (may need to delete the oracledb directory from node_modules first):

# Electron's version.
export npm_config_target=1.7.0
# The architecture of Electron, can be ia32 or x64.
export npm_config_arch=x64
export npm_config_target_arch=x64
# Download headers for Electron.
export npm_config_disturl=https://atom.io/download/electron
# Tell node-pre-gyp that we are building for Electron.
export npm_config_runtime=electron
# Tell node-pre-gyp to build module from source code.
export npm_config_build_from_source=true
# Install all dependencies, and store cache to ~/.electron-gyp.
HOME=~/.electron-gyp npm install

The last line kicked off an npm install which compiled the binary correctly for the target platform (a custom version of Node.js 7.9.0 that has a newer version of V8 than that version of Node.js usually has).