Search code examples
sails.jswaterline

Sails Waterline Oracle - installing sails-oracle-database - Error regarding oci/version


I'm a Grails (with Oracle) developer who is experimenting with Sails.js

I'm having an issue in installing the waterline oracle adapter. Steps I can do to duplicate, with a standalone node app, using Mac OS:

Following instructions on https://github.com/oracle/node-oracledb/blob/master/INSTALL.md#instosx

I placed the Oracle basic client files in my ~/lib folder by using: cp instantclient_12_2/{libclntsh.dylib.12.1,libclntshcore.dylib.12.1,libons.dylib,libnnz12.dylib,libociei.dylib} ~/lib/

In my node app, I can then install the oracle add-on by running: npm install oracledb

I can then run the examples they provide, such as by doing "node select1.js" and it successfully connects to the database and runs fine, etc

I then try to install the waterline oracle adapter by doing: npm install sails-oracle-database

It gives this error:

>[email protected] install /Users/myuser/Documents/node/oracle/node_modules/sails-oracle-database/node_modules/oracledb

>node-gyp rebuild

node-oracledb ERR! Error: Cannot find /opt/oracle/instantclient/libclntsh.dylib
node-oracledb ERR! Error: Do you need to run 'cd /opt/oracle/instantclient && ln -s libclntsh.dylib.* libclntsh.dylib'?
node-oracledb ERR! Error: See https://github.com/oracle/node-oracledb/blob/master/INSTALL.md#instosx

gyp: Call to 'INSTURL="https://github.com/oracle/node-oracledb/blob/master/INSTALL.md#instosx"; ERR="node-oracledb ERR! Error:"; if [ -z $OCI_LIB_DIR ]; then if [ -f /opt/oracle/instantclient/libclntsh.dylib ]; then echo "/opt/oracle/instantclient/"; else echo "$ERR Cannot find /opt/oracle/instantclient/libclntsh.dylib" >&2; echo "$ERR Do you need to run 'cd /opt/oracle/instantclient && ln -s libclntsh.dylib.* libclntsh.dylib'?" >&2; echo "$ERR See $INSTURL" >&2; echo "" >&2; fi; else if [ -f "$OCI_LIB_DIR/libclntsh.dylib" ]; then echo $OCI_LIB_DIR; else echo "$ERR Cannot find \$OCI_LIB_DIR/libclntsh.dylib" >&2; echo "$ERR Do you need to run 'cd \$OCI_LIB_DIR && ln -s libclntsh.dylib.* libclntsh.dylib'?" >&2; echo "$ERR See $INSTURL" >&2; echo "" >&2; fi; fi;' returned exit status 0 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:336:16)
gyp ERR! stack     at emitTwo (events.js:125:13)
gyp ERR! stack     at ChildProcess.emit (events.js:213:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:197:12)

Trying to make sense of the error... It looks like it wants me to set env variables such as: OCI_LIB_DIR However, the instructions on the oracle page it references say that is no longer necessary withe oracle-node 2 version. Is it possible the waterline-oracle adapter isn't yet compatible with this version?


Solution

  • You'll also need the SDK package of the oracle instant client. If your instant client directory already has a "sdk" folder then you're set. Next is to copy it to your "/opt/oracle/instantclient" directory.

    ➜  instantclient pwd
    /opt/oracle/instantclient
    ➜  instantclient ls
    BASIC_README             glogin.sql               libnnz12.dylib           libocijdbc12.dylib       libsqlplusic.dylib       uidrvci
    SQLPLUS_README           libclntsh.dylib          libocci.dylib            libons.dylib             ojdbc8.jar               xstreams.jar
    adrci                    libclntsh.dylib.12.1     libocci.dylib.12.1       liboramysql12.dylib      sdk
    genezi                   libclntshcore.dylib.12.1 libociei.dylib           libsqlplus.dylib         sqlplus