错误:NJS-045:无法为Node.js加载oracledb附加二进制文件

时间:2018-12-28 10:42:41

标签: node.js oracle docker node-oracledb

在我的 Node.JS 项目中,我使用了“ node-oracledb”包,该包连接到远程 ORACLE 数据库。我在Windows 10 OS中开发了该项目,并且运行良好。现在在生产服务器(CentOS)中,我通过下一个Dockerfile创建了Docker Image:

FROM node:latest
COPY / ./
EXPOSE 3001
CMD ["npm", "start"]

它创建Docker映像而没有任何错误。然后我创建了Docker容器,但不幸的是在日志中我注意到了这个错误:

/src/node_modules/oracledb/lib/oracledb.js:68
      throw new Error(nodbUtil.getErrorMessage('NJS-045', nodeInfo));
      ^

Error: NJS-045: cannot load the oracledb add-on binary for Node.js 8.12.0 (linux, x64)
Cannot load /src/node_modules/oracledb/build/Release/oracledb.node
/src/node_modules/oracledb/build/Release/oracledb.node: invalid ELF header
Node-oracledb installation instructions: https://oracle.github.io/node-oracledb/INSTALL.html
You must have 64-bit Oracle client libraries in LD_LIBRARY_PATH, or configured with ldconfig.
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/linuxx86-64soft-092277.html

    at Object.<anonymous> (/src/node_modules/oracledb/lib/oracledb.js:68:13)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/src/node_modules/oracledb/index.js:1:80)
    at Module._compile (module.js:653:30)

如何解决此问题?

我使用来自[官方文档] [2]的说明来安装客户端并设置环境变量。错误是盗窃一样。我还认为我可以尝试在docker中安装oracle客户端,但是我不知道该怎么做。您如何看待?


我更改Dockerfile。我添加以下命令:

RUM npm rebuild oracledb

它引发新的关闭错误:

/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 11.4.0 (linux, x64)
Node.js require() error was:
  DPI-1047: 64-bit Oracle Client library cannot be loaded: "libclntsh.so: cannot open shared object file: No such file or directory". See https://oracle.github.io/odpi/doc/installation.html#linux for help
Node.js require() mapped to /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 LD_LIBRARY_PATH, or configured with ldconfig.
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/linuxx86-64soft-092277.html

    at Object.<anonymous> (/node_modules/oracledb/lib/oracledb.js:65:13)
    at Module._compile (internal/modules/cjs/loader.js:723:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:734:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)
    at Module.require (internal/modules/cjs/loader.js:659:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (/node_modules/oracledb/index.js:1:80)
    at Module._compile (internal/modules/cjs/loader.js:723:30)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! saturn-backend@0.0.0 start: `node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the saturn-backend@0.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-12-28T12_06_50_714Z-debug.log

enter image description here

  [1]: https://github.com/oracle/node-oracledb
  [2]: https://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html

0 个答案:

没有答案