Hi everyone,
I am trying to setup on the MacOS. I have followed every step according to the installation instructions, but I am getting the error: ERROR: Cannot locate a 64-bit Oracle Client library: "dlopen(libclntsh.dylib, 1)"
Output: Error: DPI-1047: Cannot locate a 64-bit Oracle Client library: "dlopen(libclntsh.dylib, 1): image not found". See https://oracle.github.io/odpi/doc/installation.html#macos 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 in ~/lib or /usr/local/lib
They can be downloaded from http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html
at OracleDb.createPool (/Users/nandunbandara/Documents/designboo/rnd/verisafe/verisafe-services/verisafe-core-services/node_modules/oracledb/lib/oracledb.js:202:8)
at OracleDb.createPool (/Users/nandunbandara/Documents/designboo/rnd/verisafe/verisafe-services/verisafe-core-services/node_modules/oracledb/lib/util.js:185:19)
at /Users/nandunbandara/Documents/designboo/rnd/verisafe/verisafe-services/verisafe-core-services/src/driver/oracle/OracleDriver.ts:694:25
at new Promise (<anonymous>)
at OracleDriver.<anonymous> (/Users/nandunbandara/Documents/designboo/rnd/verisafe/verisafe-services/verisafe-core-services/src/driver/oracle/OracleDriver.ts:693:16)
at step (/Users/nandunbandara/Documents/designboo/rnd/verisafe/verisafe-services/verisafe-core-services/node_modules/tslib/tslib.js:139:27)
at Object.next (/Users/nandunbandara/Documents/designboo/rnd/verisafe/verisafe-services/verisafe-core-services/node_modules/tslib/tslib.js:120:57)
at /Users/nandunbandara/Documents/designboo/rnd/verisafe/verisafe-services/verisafe-core-services/node_modules/tslib/tslib.js:113:75
at new Promise (<anonymous>)
at Object.__awaiter (/Users/nandunbandara/Documents/designboo/rnd/verisafe/verisafe-services/verisafe-core-services/node_modules/tslib/tslib.js:109:16) {
errorNum: 0,
offset: 0
}
I do understand that this is because the client library is not available. But I have added all the libs in ~/lib. I have set all the env variables as well.
Database version: 11.2.0.1 (on AWS RDS)
`
process.platform
'darwin'
process.version
'v12.16.2'
process.arch
'x64'
require('oracledb').versionString
'4.2.0'
require('oracledb').oracleClientVersionString
Uncaught:
Error: DPI-1047: Cannot locate a 64-bit Oracle Client library: "dlopen(libclntsh.dylib, 1): image not found". See https://oracle.github.io/odpi/doc/installation.html#macos for help
`
Could you please help me with this? Thank you.
What's your OS version?
Show to us that you have everything in ~/lib.
I'm also finding similar error in nestjs platform on Mac Mojave.
I have downloaded Oracle Instant Client(Version 19_3) basic, sdk and sqlplus under $HOME. Then created a ~/lib.
ls -al ~/lib (is shown below)
lrwxr-xr-x 1 XXXXXX staff 49 Apr 15 17:10 libclntsh.dylib -> /myhomedirectory/instantclient_19_3/libclntsh.dylib
I put ~/lib directory in $PATH.
Then I try to run nestjs app from Visual Studio Code. When I run it I get same error.
Am I missing something? Interestingly, I can connect to the remote database from command line with sqlplus.
Since PATH (on macOS and Linux) is for executables, and you don't have any of these in ~/lib, you probably want to set it to /myhomedirectory/instantclient_19_3 which is where the sqlplus binary is.
Try running a Node.js script from the command line prompt (outside VSC).
Thanks for your reply.
Last two entries of my PATH is "/myhomedirectory/lib:/myhomedirectory/instantclient_19_3"
In my test directory I run following:
1) sqlplus userid/password@address:1521/servicename
Works fine....
2) Then I run the test script connect.js from the same location) - (with dbconfig.js - downloaded from Oracle Instant Client Example)
node connect.js
I get the same error from command line prompt when I run the node.js script:
Error: DPI-1047: Cannot locate a 64-bit Oracle Client library: "dlopen(libclntsh.dylib, 1): image not found". See https://oracle.github.io/odpi/doc/installation.html#macos 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 in ~/lib or /usr/local/lib
They can be downloaded from http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html
at OracleDb.getConnection (myhomedirectory/Documents/Tests/node_modules/oracledb/lib/oracledb.js:287:10)
at /myhomedirectory/Documents/Tests/node_modules/oracledb/lib/util.js:202:16
at new Promise (
at OracleDb.getConnection (/myhomedirectory/Documents/Tests/node_modules/oracledb/lib/util.js:190:14)
at run (/myhomedirectory/Documents/Tests/connect.js:12:33)
at Object.
at Module._compile (internal/modules/cjs/loader.js:1156:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14) {
errorNum: 0,
offset: 0
Thanks.**
I have upgraded to Mac Catalina. I have tried with both 19_3 and 18_1 version of Instant Client.
I have put the instantclient_19_3 folder under ~/lib.
Also, I had to set LD_LIBRARY_PATH (and not PATH) in .bash_profile.
echo $LD_LIBRARY_PATH
/myhomedirectory/lib/instantclient_19_3
With this bare-bone program (downloaded from node-oracledb example) :
node connect.js
Now I can successfully connect to database (tested with both 19_3 and 18_1).
However, when I run the nestjs app from command line or from VSC - the same problem is coming up. for both versions
[Nest] 10517 - 04/16/2020, 3:22:39 PM [TypeOrmModule] Unable to connect to the database. Retrying (1)... +1ms
Error: DPI-1047: Cannot locate a 64-bit Oracle Client library: "dlopen(libclntsh.dylib, 1): image not found". See https://oracle.github.io/odpi/doc/installation.html#macos 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 in ~/lib or /usr/local/lib
They can be downloaded from http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html
Thanks.
Catalina is not officially supported by current Instant Clients; I am not upgrading yet! Some users have workarounds in https://github.com/oracle/python-cx_Oracle/issues/341 Good luck.
I Confirm as I had an update yesterday to Catalina. Big change for the environment: the bash shell has been replaced by zsh ... maybe investigate that direction for your problem.
Which node version are you using? I changed to node v13.13.0 from v14.0.0 and got it to work. I'm using 18_1 version of Instant Client.
The Node.js packages have just changed to notarized builds, which are causing problems for node-oracledb loading libclntsh even on Mojave. I don't have a full picture yet.
I started having this issue when I recently upgraded to Node v12.16.2. After changing back to v12.16.1 it worked without issue
Yes, recent versions of Node.js have been compiled differently: https://nodejs.org/en/blog/release/v12.16.2/
Still could not find a solution to this. So I decided to use a Linux docker image with the libraries. Does the job.
I started having this issue when I recently upgraded to Node v12.16.2. After changing back to v12.16.1 it worked without issue
Worked for me as well. I also installed latest python 2.7 - as I understood it right in some cases the prepacked python which comes with macOS may cause issues with node-oracledb during the instalation (node-gyp).
The whole process I have done:
https://github.com/oracle/node-oracledb/issues/1244#issuecomment-624646368
Although in the documentation says that you don't need to set the LD_LIBRARY_PATH for an instant client above of 12.1, in Mac OS Catalina you have to set it to your /opt/oracle/instantclient_19_3 directory, if not you will not be able to execute oracle in Node.
@reybis that also seems to work on Mojave, though I haven't tested extensively.
The other thing to try is:
diff --git a/binding.gyp b/binding.gyp
index f6d8d624..b094793f 100644
--- a/binding.gyp
+++ b/binding.gyp
@@ -75,7 +75,7 @@
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
"GCC_ENABLE_CPP_RTTI": "YES"
},
- "libraries" : ['-ldl', '-lpthread']
+ "libraries" : ['-ldl', '-lpthread', '-Wl,-rpath,$$HOME/lib', '-Wl,-rpath,/usr/local/lib']
}
],
[
and then rebuild node-oracledb. This seems to work on Mojave. I have this in my ~/lib:
libclntsh.dylib -> /Users/cjones/instantclient_19_3/libclntsh.dylib
Any testing would be appreciated, particularly on Catalina.
@reybis some questions: On Catalina, did you do anything to SIP or the instant client libraries? Or did you just set LD_LIBRARY_PATH? Does LD_LIBRARY_PATH propagate to subshells for you (see https://github.com/oracle/node-oracledb/issues/231)?
Just adding to the thread that I followed @casperle suggestion (https://github.com/oracle/node-oracledb/issues/1244#issuecomment-624646368) and they worked beautifully in a fresh-installed Catalina 10.15.4
Also see the official Node.js documentation about Catalina.
Is there no way to use node-oracledb with node 12.16.2 and Catalina?
Hi!
I am having similar issues! I upgraded to Catalina. 19_3 stopped working. I tried to connect to the database, using cx_Oracle client. I get the following error:
error msgDPI-1047: Cannot locate a 64-bit Oracle Client library: "dlopen(libclntsh.dylib, 1)
Python, cx_Oracle Client and cx_oracle are 64 bit. Gave permissions (777) to /opt/oracle.
I'm not using unbundled Python
@PayalPandey1 this is the repo for node-oracledb. The cx_Oracle issue you want is here.
@cjbj thanks!
@reybis some questions: On Catalina, did you do anything to SIP or the instant client libraries? Or did you just set LD_LIBRARY_PATH? Does LD_LIBRARY_PATH propagate to subshells for you (see #231)?
Yes, when the LD_LIBRARY_PATH is set, it will propagate to all subshells. 馃
I followed below steps to fix this issue:
@deepanksinghal what Node.js version did you use? And did you need to do both 2 & 3, or would just 3 have worked?
@deepanksinghal what Node.js version did you use? And did you need to do both 2 & 3, or would just 3 have worked?
I'm on Node v14.2, macOS Catalina v10.15. Although I did both 2 and 3, it seems only 3 would have worked. However steps 4,5,6 are required.
@reybis I found the variable didn't propagate to subshells.
@deepanksinghal thanks for the update. I didn't need to force the use of Python 2.
orcl@cjmac test % cat v.js
const oracledb = require('oracledb');
const config = { user: 'cj', password: 'cj', connectString: 'localhost/orclpdb1' };
async function run() {
let connection;
try {
connection = await oracledb.getConnection(config);
const result = await connection.execute(`SELECT TO_CHAR(CURRENT_DATE, 'DD-Mon-YYYY HH24:MI') AS D FROM DUAL`);
console.log(result);
} catch (err) {
console.error(err);
} finally {
if (connection) {
try {
await connection.close();
} catch (err) {
console.error(err);
}
}
}
}
run();
Without any environment set the oracle client isn't found:
orcl@cjmac test % node v.js
Error: DPI-1047: Cannot locate a 64-bit Oracle Client library: "dlopen(libclntsh.dylib, 1): image not found". See https://oracle.github.io/odpi/doc/installation.html#macos for help
[ . . .]
With LD_LIBRARY_PATH set the client was found. (The ORA error was expected, since I didn't have a DB running. But it does show that node-oracledb found Instant Client):
orcl@cjmac test % export LD_LIBRARY_PATH=$HOME/instantclient_19_3
orcl@cjmac test % node v.js
node v.js
[Error: ORA-12547: TNS:lost contact] { errorNum: 12547, offset: 0 }
In a subshell the LD_LIBRARY_PATH variable was ignored:
orcl@cjmac test % cat t.sh
#!/bin/sh
node v.js
orcl@cjmac test % ./t.sh
Error: DPI-1047: Cannot locate a 64-bit Oracle Client library: "dlopen(libclntsh.dylib, 1): image not found". See https://oracle.github.io/odpi/doc/installation.html#macos for help
[ . . .]
If I set LD_LIBRARY_PATH in t.sh the app worked.
We have some other alternative ways that you can configure node-oracledb to find Instant Client.coming in node-oracledb 5. They'll probably get pushed to the master branch at the end of the week.
@cjbj I just wanted to give you an update. While I was able to run my app through 'node' command (after doing all the steps I mentioned above), I wasn't able to run it through nodemon.
I had to finally turn off System Integrity Protection in Mac to make that work.
@deepanksinghal the fact that it didn't work in nodemon is not surprising, since the LD_LIBRARY_PATH variable won't propagate.
I don't like the idea of turning off SIP.
Try using the feature we just pushed to the master branch. Use npm install oracle/node-oracledb.git#master to compile & build the module, see Installing GitHub clones and zip files.
Then you can do something like this:
ln -s ~/instantclient_19_3/libclntsh.dylib node_modules/oracledb/build/Release
or use the new method:
const oracledb = require('oracledb');
try {
oracledb.initOracleClient({libDir: '/Users/your_username/instantclient_19_3'});
} catch (err) {
console.error('Whoops!');
console.error(err);
process.exit(1);
}
The development doc is here.
Note to other readers: On Linux, using initOracleClient() like the above example won't do what you think it will do with current Oracle client libraries: you still need to use ldconfig or set LD_LIBRARY_PATH.
And note with node-oracledb 5.0.0-dev on macOS that putting Instant Client in ~/lib will mostly not be usable, depending on your Node.js version and macOS version.
I am having the same issue...
my system and versions
macOS catalina
node v12.18.0
npm v6.14.4
oracle instant client v19.3.0.0.0
oracledb v4.2.0
after reading this thread would the recommended solution for me be to follow the steps in a post above?
-Uninstall node-oracledb. -> npm uninstall oracledb
-Install it again with use python option:
-npm install --python=<your_path>/python-2.7/bin/python oracledb
- set LD_LIBRARY_PATH:
export LD_LIBRARY_PATH=~/lib:<your_path>/instantclient_19_3
-Open System Preferences -> General Tab. Keep it open.
-Try connecting to Oracle database.
-You will get 'Developer Unverified' message. Check System Preferences window and click Allow Anyway.
-Repeat it for all 3-4 libraries.
Probably not. I don't believe you need to recompile - I didn't.
I solved my issues by following these steps on mac with Catalina:
@wwissingTechtonic do you happen to have DYLD_LIBRARY_PATH or similar set somewhere? I don't see how copying the Instant Client to /opt would help without this.
I didn't have to downgrade or install globally. With 14.4 on Catalina using node-oracledb 4.2 I could simply set DYLD_LIBRARY_PATH to the location of my Instant Client files. Plus do the 'allow' clickthrough for the Instant Client libraries.
With the upcoming node-oracledb 5 (that you can currently compile from the master branch), there were the other options I mention earlier in this issue.
Yes, that is another step I had forgotten to mention thanks,
so setting DYLD_LIBRARY_PATH in the same terminal as I was running the npm script with this command -
DYLD_LIBRARY_PATH='path to instantclient files'
This is working for me after a lot of troubleshooting. I think the whole issue is caused by MacOS Gatekeeper. It is silently denying access to the client executable.
I followed deepanksinghal's steps noted above:
Uninstall node-oracledb. -> npm uninstall oracledb
Install it again with use python option:
npm install --python=
set LD_LIBRARY_PATH:
export LD_LIBRARY_PATH=~/lib:
Then because on Mojave I don't get an option to approve running the software I needed to run
sudo spctl --master-disable in terminal.
Now everything works.
Try using the feature we just pushed to the master branch. Use
npm install oracle/node-oracledb.git#masterto compile & build the module, see Installing GitHub clones and zip files.
This resolved it for me. @cjbj, When do you expect the 5.0 branch to be published to NPM?
Thanks.
@jtibble thanks for the confirmation.
We are at feature freeze for 5.0.0-dev
If you get a chance to run some testing with it and let us know how it behaves, that would help us get it out sooner.
@jtibble as you might have seen from other Issue updates, node-oracledb 5 is on npm. Check out the new macOS installation doc and new initialization doc.
Most helpful comment
I started having this issue when I recently upgraded to Node v12.16.2. After changing back to v12.16.1 it worked without issue