This post was updated on 20 March, 2019 to reflect changes in the way yum configuration works.
A few months ago we added dedicated repositories for Node.js to the Oracle Linux yum server. These repos also include an RPM with the Oracle Database driver for Node.js, node-oracledb, so you can connect your Node.js application to the Oracle Database.
In this post I describe the steps to install Node.js 10 and node-oracledb Node.js to Oracle Database. If you are in a rush or want to try this out in a non-destructive way, I recommend you use the latest Oracle Linux 7 Vagrant box .
To set up your system to access Node.js and Oracle Instant Client repos on Oracle Linux yum server, install the oracle-nodejs-release-el7 and oracle-release-el7 RPMs. As of this writing, the Node.js 10 repo will be enabled by default when you install the Oracle Node.js repelase RPM
$ sudo yum -y oracle-node-release-el7 oracle-release-el7
Next, install Node.js 10 and the compatible node-oracledb, making sure to temporarily disable the EPEL repository to prevent the wrong version of Node.js getting installed.
$ sudo yum -y install --disablerepo=ol7_developer_EPEL nodejs node-oracledb-node10
node-oracledb depends on Oracle Instant Client. During OpenWorld 2018 we released Oracle Instant Client 18.3 RPMs on Oracle Linux yum server in the ol7_oracle_instantclient and ol6_oracle_instantclient repositories, making installation a breeze. Assuming you have enabled the repository for Oracle Instant Client appropriate for your Oracle Linux release, it will be installed as a dependency. As of release 3.0, node-oracledb is built with Oracle Client 18.3, which connects to Oracle Database 11.2 and greater. Older releases of Oracle Instant Client are available on OTN.
Add the Oracle Instant Client to the runtime link path.
$ sudo sh -c "echo /usr/lib/oracle/18.3/client64/lib > /etc/ld.so.conf.d/oracle-instantclient.conf" $ sudo ldconfig
I copied this file from the examples in the node-oracledb Github repo. Running this will tell us whether Node.js can connect to the database. Copy this code into a file called connect.js.
The file below comes from the same GitHub repo. Copy the code into a file called dbconfig.js and edit it to include your Database username, password and connect string.
Before running connect.js, make sure NODE_PATH is set so that the node-oracledb module can be found.
$ export NODE_PATH=`npm root -g` $ node connect.js Connection was successful!