简体   繁体   English

尝试使用IBM_DB时出现节点JS绑定错误

[英]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. 尝试将IBM_DB用于db2访问时出现以下错误。

$ 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. 我知道这是一个已有1年历史的问题,但我认为这里至少需要一个正确的解释/答案,这样以后的读者才不会感到困惑。

Error: Module version mismatch. 错误:模块版本不匹配。 Expected 47, got 46. 预期为47,得到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). 您通常会在Windows平台上遇到此错误,而实际上这并不是错误或缺陷,这仅仅是因为node-ibm_db不支持特定的节点版本(您正在Windows平台上安装node-ibm_db所使用)。

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. 原因:node-ibm_db在模块内为特定的主节点版本(例如4.x,6.x等)提供了预编译的节点二进制文件,模块在安装时不编译(仅在Windows上),它使用预编译的编译后的二进制文件以进行安装和设置。

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. 因此,如果您使用的是最新版本的nodejs主版本,尤其是该版本,即node-ibm_db目前尚不支持(或者只是预编译的二进制文件不可用),则会出现此错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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