Vscode: Debugger crashing - "Error: The module '/bcrypt_lib.node' was compiled against a different Node.js version..."

Created on 12 Dec 2018  ·  3Comments  ·  Source: microsoft/vscode

CPUs

| Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz (8 x 816)
-- | --

GPU Status

| 2d_canvas: unavailable_softwarechecker_imaging: disabled_offflash_3d: unavailable_softwareflash_stage3d: unavailable_softwareflash_stage3d_baseline: unavailable_softwaregpu_compositing: unavailable_softwaremultiple_raster_threads: enabled_onnative_gpu_memory_buffers: disabled_softwarerasterization: unavailable_softwarevideo_decode: unavailable_softwarevideo_encode: unavailable_softwarewebgl: enabled_readbackwebgl2: unavailable_off

Load (avg) | 1, 1, 1

Memory (System) | 15.42GB (4.06GB free)

Process Argv | --disable-gpu

Screen Reader | no

VM | 0%

Version: 1.29.1
Commit: bc24f98b5f70467bc689abf41cc5550ca637088e
Date: 2018-11-15T19:07:43.495Z
Electron: 2.0.12
Chrome: 61.0.3163.100
Node.js: 8.9.3
V8: 6.1.534.41
Architecture: x64

Steps to Reproduce:

  1. Have a node server using the module bcrypt
  2. Try to user the debugger with the following settings;

    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${workspaceFolder}/build/index.js",
            "preLaunchTask": "tsc: build - tsconfig.json",
            "outFiles": [
                "${workspaceFolder}/build/**/*.js"
            ]
        }
    ]
}
  1. Note the following error:
module.js:682
  return process.dlopen(module, path._makeLong(filename));
                 ^
Error: The module '/home/calebjay/Documents/work/internal-admin/node_modules/bcrypt/lib/binding/bcrypt_lib.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 64. This version of Node.js requires
NODE_MODULE_VERSION 57. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).

I have attempted

  1. rm -rf node_modules followed by npm install
  2. nvm use with various versions (the package.json lists "node": "10.13.0",)
  3. npm rebuild

The error does not occur when the app is built and served outside of the vscode debugger - the error is unique to the debugger.

Does this issue occur when all extensions are disabled?: Yes

debug

All 3 comments

@komali2
What is your default node.js version?
run node --version outside of VS Code and inside VS Code's integrated terminal.
Do you see the same version in both cases?

If you are using "nvm" or "nvs" you can add a "runtimeVersion": "x.y.z" to your launch config to make VS Code use a specific version of node.js.

Oh I see, I hadn't considered that.

npm version inside the integrated VSCode terminal is 10.13.0, and inside my actual terminal was 8.1... something. So, outside vscode I did

nvm use 10.13.0

npm rebuild

Then, I tried inside vscode to use the debugger, however, I'm still getting the following error:

was compiled against a different Node.js version using
NODE_MODULE_VERSION 64. This version of Node.js requires
NODE_MODULE_VERSION 57. Please try re-compiling or re-installing

This probably isn't a VSCODE bug, now that I see there's a difference in the terminal versions. Thank you anyway for your help. I'm a bit confused... I've no idea what versions of node to map against NODE_MODULE_VERSION 64 or 57, I've never seen them referred to that way...

If you use nvm, you will have to make sure that VS Code picks up nvm's node version (this is not as simple as it seems because nvm does not use an environment variable for this but a shell function instead; see https://stackoverflow.com/questions/44700432/visual-studio-code-to-use-node-version-specified-by-nvm).

A more explicit (and therefore my recommended) approach is to use add a "runtimeVersion": "8.1.0"to the launch config.


I don't no whether a npm rebuildis sufficient to rebuild a native module against another version of node.

Was this page helpful?
0 / 5 - 0 ratings