oracle / node-oracledb

Oracle Database driver for Node.js maintained by Oracle Corp.
http://oracle.github.io/node-oracledb/
Other
2.25k stars 1.08k forks source link

vscode + WSL2 64 ubuntu-18.04 DPI-1047: Cannot locate a 64-bit Oracle Client library. help me plz #1522

Closed mike-hor closed 2 years ago

mike-hor commented 2 years ago
  1. What versions are you using? vscode + WSL2 64 ubuntu-18.04

  2. Describe the problem

    I use vscode and wsl2 ubuntu:18.04 to develop nodejs app. I download the oracle Instant Client unzip to the path: /home/hyh/ops-next/server/instantclient_11_2/linux and then add env export LD_LIBRARY_PATH=/home/hyh/ops-next/server/instantclient_11_2/linux:$LD_LIBRARY_PATH but,i get error.

    • thorw error, Error: DPI-1047: Cannot locate a 64-bit Oracle Client library: "/home/hyh/ops-next/server/instantclient_11_2/linux/libclntsh.so: cannot open shared object file: No such file or directory"
    • and i add symbol link
      cd  /home/hyh/ops-next/server/instantclient_11_2/linux
      ln -s libclntsh.so.11.1 libclntsh.so
    • thorw another error Error: DPI-1047: Cannot locate a 64-bit Oracle Client library: "libnnz11.so: cannot open shared object file: No such file or directory"

      but i find libnnz11.so in the path /home/hyh/ops-next/server/instantclient_11_2/linux ,the error make me so confused.

    • so,what shoud i do,by the way code running well in windwos.
  3. my code

    
    const oracledb = require("oracledb");
    const path = require("path");
    const platform = process.platform;
    const libDir = platform == 'win32' ? path.resolve(process.cwd(), 'instantclient_11_2', 'windows') : path.resolve(process.cwd(), 'instantclient_11_2', 'linux');
    console.log(libDir);  //    /home/hyh/ops-next/server/instantclient_11_2/linux
    try {
    oracledb.initOracleClient({
        libDir
    });
    oracledb.outFormat = oracledb.OUT_FORMAT_OBJECT;
    } catch (err) {
    if (err.message.indexOf('NJS-077') < 0) {
        console.log(err)
    }
    }
cjbj commented 2 years ago
mike-hor commented 2 years ago

tks,I reslove the problem. as you say,just export $LD_LIBRARY_PATH ,not use libDir(musut in node shell,before node runing).