简体   繁体   中英

Node JS Binding error when trying to use IBM_DB

I am getting the below error when trying to use IBM_DB for db2 access.

$ node nodetest.js
C:\Users\workspace\nodetest\node_modules\bindings\bindings.js:79
    throw e
    ^

Error: Module version mismatch. Expected 47, got 46.
at Error (native)
at Object.Module._extensions..node (module.js:440:18)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at bindings (C:\Users\workspace\nodetest\node_modules\bindings\bindings.js:74:15)
at Object.<anonymous> (C:\Users\workspace\nodetest\node_modules\ibm_db\lib\odbc.js:27:31)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)

Here is the code I'm using:

var http = require("http");
var ibmdb = require("ibm_db");
console.log("Test program to access DB2 sample database");
http.createServer(function (request, response) {
  response.writeHead(200, {'Content-Type': 'text/plain'});
  response.end('Hello World\n');
}).listen(8081);
console.log('Server running at 127.0.0.1:8081/');

Can someone please help me on this ?

I know this is a 1 year old question but I think it requires at least one correct explanation/answer for that question here, so that future readers might not get confused.

Error: Module version mismatch. Expected 47, got 46.

You will encounter with this error mostly on Windows platform, and this is actually not a bug or defect, this is simply because node-ibm_db does not support particular node version (which you are using for installing node-ibm_db on windows platform).

Reason: node-ibm_db provides pre-compiled node binaries within the module for particular main node-versions (like 4.x, 6.x etc),module do not compile at installing time (on windows only), it uses the pre-compiled binaries to installation and setup.

Hence if you use a latest major version of nodejs and specifically that,- which node-ibm_db is not supporting yet (or simply pre-compiled binaries are not available), you will get this error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM