node项目oracledb连接oracle数据库报错You must have the 64-bit Oracle Instant Client Basic

1,019 阅读1分钟

报错信息:DPI-1047: Cannot locate a 64-bit Oracle Client library: "dlopen(libclntsh.dylib, 1): image not found". See https://oracle.github.io/node-oracledb/INSTALL.html for help Node-oracledb installation instructions: https://oracle.github.io/node-oracledb/INSTALL.html You must have the 64-bit Oracle Instant Client Basic or Basic Light package libraries in /usr/local/lib or set by calling oracledb.initOracleClient({libDir: "/my/instant_client_directory"}). Oracle Instant Client can be downloaded from https://www.oracle.com/database/technologies/instant-client/macos-intel-x86-downloads.html

是因为本地安装缺少Oracle Instant Client(即时客户端)

根据报错提示到 oracle网站下载文件,我下载的是instantclient-basic-macos.x64-19.8.0.0.0dbru.zip

文件下载后需要配置,参考网址 oracle.github.io/odpi/doc/in…

Oracle 即时客户端 Zip 文件

要安装 Oracle Instant Client zip 文件:

  1. Oracle下载 19、18、12 或 11.2“Basic”或“Basic Light”zip 文件。选择与您的应用程序架构相匹配的 64 位或 32 位软件包。大多数应用程序使用 64 位。

  2. 将包解压缩到您的应用程序可以访问的单个目录中。例如,在终端中,您可以解压缩:

    mkdir /opt/oracle
    cd /opt/oracle
    unzip /your/path/to/instantclient-basic-macos.x64-19.8.0.0.0dbru.zip
    

配置 Oracle Instant Client 

有几种替代方法可以告诉您的应用程序您的 Oracle Instant Client 库在哪里。

我选择的是
或者,您可能决定使用 RPATH 选项(如`-Wl,-rpath,/usr/local/lib`. 然后您可以将 Oracle Instant Client 链接到该目录,例如:

ln -s /opt/oracle/instantclient_19_8/libclntsh.dylib /usr/local/lib/

再次使用oracledb连接数据库就不会报错了