oracle / node-oracledb

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

Issue regarding using packages npm install instantclient and oracledb #1220

Closed sachindkagrawal18 closed 4 years ago

sachindkagrawal18 commented 4 years ago

Issue regarding using packages npm install instantclient and oracledb

We are looking for a way to include both node packages instantclient and oracledb in our project so that there are no manual steps of copying client libraries.

Steps we followed 1) npm install instantclient We provided all the required oracle login details and prompted Y and it installed below files by creating an instantclient folder in our project. /Users/SAgrawal/Desktop/automationsvcs/instantclient BASIC_README libclntsh.dylib.11.1 libociei.dylib ojdbc6.jar xstreams.jar adrci libnnz11.dylib libocijdbc11.dylib sdk genezi libocci.dylib.11.1 ojdbc5.jar uidrvci

2) As per instructions on npm page for instantclient, did the below of pointing below variables to instant client folder OCI_LIB_DIR=/Users/SAgrawal/Desktop/automationsvcs/instantclient/ OCI_INC_DIR=/Users/SAgrawal/Desktop/automationsvcs/instantclient/ export PATH=/Users/SAgrawal/Desktop/automationsvcs/instantclient:$PATH

And, versions are as below Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production Plain Node version v10.16.0

3) Also, in my script , I had done below process.env['PATH'] = path.join("/Users/SAgrawal/Desktop/automationsvcs", '/instantclient') + ';' + process.env['PATH']; const oracledb = require('oracledb');

But, still, we get the below error on trying to use oracledb

{ Error: DPI-1047: Cannot locate a 64-bit Oracle Client library: "dlopen(libclntsh.dylib, 1): image not found".

Few points I would like to clarify 1) We are interested in having instantclient files using some package only and not install instant client manually and then copy to any path since we would like to install using the same way to servers. We do not want any manual steps of copying files to ~/lib for Mac or any other path for linux servers. Currently, I am doing this process while locally running on my macbook but would like to extend the same process of using instantclient node package to install to servers also.

Requesting you to please help into this regards and let me know if I am missing out anything. Thanks & Regards, Sachin

cjbj commented 4 years ago

ssue regarding using packages npm install instantclient and oracledb

We are looking for a way to include both node packages instantclient and oracledb in our project so that there are no manual steps of copying client libraries.

Steps we followed

npm install instantclient

This is very obsolete. There is no click-through required now; you can just 'wget' or 'curl' the zip packages directly from your computer (except for macOS until the next revision...)

As per instructions on npm page for instantclient, did the below of pointing below variables to instant client folder OCI_LIB_DIR=/Users/SAgrawal/Desktop/automationsvcs/instantclient/ OCI_INC_DIR=/Users/SAgrawal/Desktop/automationsvcs/instantclient/

These haven't been used by node-oracledb for a long time.

export PATH=/Users/SAgrawal/Desktop/automationsvcs/instantclient:$PATH

And, versions are as below Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production Plain Node version v10.16.0

Also, in my script , I had done below process.env['PATH'] = path.join("/Users/SAgrawal/Desktop/automationsvcs", '/instantclient') + ';' + process.env['PATH'];

What were you trying to do here? Are you confusing Windows use of PATH with what is used on macOS?

const oracledb = require('oracledb'); But, still, we get the below error on trying to use oracledb

{ Error: DPI-1047: Cannot locate a 64-bit Oracle Client library: "dlopen(libclntsh.dylib, 1): image not found".

Please read the current install documentation and follow it!

Few points I would like to clarify

We are interested in having instantclient files using some package only and not install instant client manually and then copy to any path since we would like to install using the same way to servers. We do not want any manual steps of copying files to ~/lib for Mac or any other path for linux servers. Currently, I am doing this process while locally running on my macbook but would like to extend the same process of using instantclient node package to install to servers also. Requesting you to please help into this regards and let me know if I am missing out anything. Thanks & Regards, Sachin

On Windows you can put the Instant Client libraries with the node-oracledb binary e.g. in node_modules\oracledb\build\Release. This doesn't work on other platforms, though is some effort going on that may change the way Oracle Instant Client is built. But that is a long way off, if it works.

On macOS and Linux you will need to set the system library search path before you start the node.js executable. This is a bit trickier on macOS, because Apple's SIP gets in the way.

There may be some hacks on the web for modifying Oracle libraries that get you part way, but you would still need an updated node-oracledb (technically ODPI-C).

sachindkagrawal18 commented 4 years ago

Thanks Christopher for your comments. Mostly, interested in the node-oracledb on linux server part (Mac is my local machine).

So, would like to confirm below 1) For a linux server, if we put the libraries of instant client at any path, say /etc/instantclient folder and set the LD_LIBRARY_PATH to this instantclient folder. Now, for doing npm install oracledb, are there any other pre-requisites , as node-oracledb installation is dependent on oracle instant client?

2) And if we set LD_LIBRARY_PATH=/etc/instantclient while starting the node server as LD_LIBRARY_PATH=/etc/instantclient node server.js will this resolve the error when we try oracledb through linux server?

3) Can you please elaborate more on updated node-oracle (ODPI-C). If I am taking the latest node oracledb version 4.2 through npm, is that an updated version which you are referring to?

Please let me know about this. Thanks & Regards, Sachin

cjbj commented 4 years ago

For a linux server, if we put the libraries of instant client at any path, say /etc/instantclient folder and set the LD_LIBRARY_PATH to this instantclient folder. Now, for doing npm install oracledb, are there any other pre-requisites , as node-oracledb installation is dependent on oracle instant client?

Check the installation instructions.

And if we set LD_LIBRARY_PATH=/etc/instantclient while starting the node server as LD_LIBRARY_PATH=/etc/instantclient node server.js will this resolve the error when we try oracledb through linux server?

Try it out. Or export the variable before running Node.js.

On Linux, the Oracle client libraries need to be in the system library search path. If you use recent Instant Client Linux RPMs, the search path is automatically updated. If you use Instant Client ZIPs, then you can set LD_LIBRARY_PATH, or run ldconfig. This is all in the instructions.

Can you please elaborate more on updated node-oracle (ODPI-C). If I am taking the latest node oracledb version 4.2 through npm, is that an updated version which you are referring to?

I'm speaking about a far future version that is not yet designed or planned. Like on Windows, it would look in the Release directory on Linux for Instant Client. It doesn't do that now because libclntsh will fail to load libnnz

sachindkagrawal18 commented 4 years ago

Thanks Christopher for all your answers so far.

One quick query I had is there any node package for instantclient which bundles all the instant client libraries and extracts them on npm install because that would be really useful.

I tried one of the library instantclient and tried to install by npm install instantclient but it does not extracts all the required client files. Example client files missing include libclntsh.dylib as well as all the new versions files like libclntsh.dylib.18.1 & libclntsh.dylib.19.1 are missing.

Please let me know about this. Thanks & Regards, Sachin

cjbj commented 4 years ago

One quick query I had is there any node package for instantclient which bundles all the instant client libraries and extracts them on npm install because that would be really useful.

There doesn't seem to be an inbuilt Node.js package that handles ZIP archives, so we haven't created an installer. You could write your own with one of the zip package libraries on npm. (zlib handles only compression, not archiving - if I'm not mistaken).

cjbj commented 4 years ago

Closing - no activity.