Mike Lischke Mike Lischke - 3 years ago 282
Node.js Question

Error: Module version mismatch. Expected 47, got 48

I'm writing a Visual Studio Code extension which uses a native node.js module. When I try to debug this extension in vscode I get the error message from above, when loading the native module (when commenting out the

require()
call no error comes up). It tried quite a few steps to overcome + test this:


  • npm uninstall native-module
    followed by a
    npm install native-module --save-dev
    in my vscode extension folder, this compiled the native module completely and without problems.

  • Completely cleaned my node_modules folder in the extension and did again the
    npm install --save-dev
    .

  • Installed node.js again, both LTS and current. With LTS the error message changes to: expected 47, got 46.

  • Installed latest vscode (August recovery build)

  • Launched a node session in my vscode extension folder and loaded my native module. This works nicely.

  • Read the various questions and comments here on SO. They mostly recommend what I described above.



Still, I cannot get vscode to accept my native module. What can I do? From the above steps it appears as if vscode has been built with a node.js version between current and LTS. Can I force my native module somehow to use a specific version?

Btw. what do those numbers 48, 47, 46 etc. actually mean? The node.js version is of course in the typical form: major.minor.build and nothing of that matches the above version numbers.

Update:

ok, I found what those numbers mean: https://nodejs.org/en/download/releases/

Answer Source

Once you know what those numbers in the error message mean it's easy to solve the issue. Simply install the node.js version that is expected. In my case it's node.js 5.12.0.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download