[SOLVED] NJS-045 DPI-1047: 64-bit Oracle Client library cannot be loaded

This is a solution for an exception occurred when you try to run Node.js application required Oracle Database.

Problem
Unable to run Node.js application because of the DPI-1047 exception:

Error: NJS-045: cannot load the oracledb add-on binary for Node.js 6.11.4 (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 /home/.../node_modules/oracledb/build/Release/oracledb.node
Node-oracledb installation instructions: https://github.com/oracle/node-oracledb/blob/master/INSTALL.md
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> (/home/.../node_modules/oracledb/lib/oracledb.js:65:13)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/home/.../node_modules/oracledb/index.js:1:80)
at Module._compile (module.js:570:32)

 

Cause
There may be several reasons why you get the exception:

  1. Missing required Oracle Database Instant Client libraries.
  2. LD_LIBRARY_PATH environment variable is not set correctly
  3. Sufixes in *.so libraries

 

Solution A
First of all you should follow the instructions. Remember to:

  • install Oracle Database Instant Client libraries in proper version. If you use wrong version you can get the ORA-01804 exception.
  • install libaio/libaio1 package
    sudo yum install libaio
    sudo apt-get install libaio1

 

Solution B
If you still get the exception ensure that you set LD_LIBRARY_PATH correctly:

cd my_app_directory
export LD_LIBRARY_PATH=/<your path to the location of instantclient>/instantclient_12_2
node index.js

If you use Visual Studio Code, you can also add environment variable to the lauch.json file.

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [

        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${workspaceFolder}/index.js",
            "env": {"LD_LIBRARY_PATH": "/home/.../instantclient_12_2"},
        }
    ]
}

 

Solution C
Go to the location of instantclient and ensure that libclntsh.so file ends with *.so extenstion. Im my case it was libclntsh.so.12.1 . The solution is to create symbolic link:

ln -s libclntsh.so.12.1 libclntsh.so

or to rename/copy the library:

cp libclntsh.so.12.1 libclntsh.so

3
Leave a Reply

avatar
2 Comment threads
1 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
3 Comment authors
huozhihuilukasz.cieslaMostafa Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Mostafa
Guest
Mostafa

Hi, I followed the instruction that you provided, but still I have issues regarding instant client installation. I have successfully installed Oracle SQL Developer and imported in python as cx_Oracle, however I cannot link instant client to it and I get this error:

DatabaseError: 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.

I was wondering if you can help me with that.

huozhihui
Guest
huozhihui

In Ubuntu, can you connect to the database with the dynamic library of Oracle client only?

Close Menu