如何将Oracle DB与Node.js连接

时间:2019-01-09 12:33:03

标签: node.js oracle


我想知道有什么方法可以将节点js与oracle db连接。 我正在尝试通过使用节点模块require('oracledb')将nodejs与oracle db连接,但无法正常工作。

var oracledb = require('oracledb');
oracledb.getConnection({
    user          : "*******",
    password      : "*******",
    connectString : "192.168.177.106/mymmsrev-local"
  },function(err, connection){
    if (err) { 
        console.error(err);
        return;
    }
});

得到以下错误:

    D:\projects\ImportExport\node_modules\oracledb\lib\oracledb.js:65
      throw new Error(nodbUtil.getErrorMessage('NJS-045', nodeInfo));
      ^

Error: NJS-045: cannot load the oracledb add-on binary for Node.js 8.9.4 (win32, x64)
Node.js require() error was:
  DPI-1047: 64-bit Oracle Client library cannot be loaded: "The specified module could not be found". See https://oracle.github.io/odpi/doc/installation.html#windows for help
Node.js require() mapped to D:\projects\ImportExport\node_modules\oracledb\build\Release\oracledb.node
Node-oracledb installation instructions: https://oracle.github.io/node-oracledb/INSTALL.html
You must have 64-bit Oracle client libraries in your PATH environment variable.
If you do not have Oracle Database on this computer, then install the Instant Client Basic or Basic Light package from
http://www.oracle.com/technetwork/topics/winx64soft-089540.html
A Microsoft Visual Studio Redistributable suitable for your Oracle client library version must be available.

2 个答案:

答案 0 :(得分:1)

错误消息中似乎显示了答案。通常,您需要一些Oracle客户端库,可以从Oracle站点免费下载(另请参阅错误消息中的链接)。

答案 1 :(得分:0)

您可以尝试运行:npm rebuild oracledb

如果不起作用,请尝试在这里https://github.com/oracle/node-oracledb/issues/577