DEV Community

MohananT
MohananT

Posted on

Install & Configure oracledb node module in windows

Hi Friends, I am new to this community and this is my first post.TADA!!. Ok, coming to the topic recently when i came across a requirement to use oracledb as a backend to nodejs server. I believed npm install of oracledb will suffice but sooner or later after reading the documentation of oracle and its npm library support. I figured it out, this is going to be a daunting task. It took me a day to install and establish connection between nodejs and oracle server.

Installation of oracledb

As per oracledb node github page Link, the command npm install oracledb must be enough to install orabledb package but if and only if your computer system has binary of oracledb which we would not have it anyway. So, to get it installed i followed the following steps which I would recommend everyone to follow sequentially to get started in no time.

  1. Install Python
    • After installing python, set the environment variable for python. Under System variables in PATH, add/append python.exe's path.
  2. Install a C Compiler with support for C++ 11
    • Install Visual Studio 2015 Community Edition Link
    • In case, if the compiler is not working, we need to set it up. This is not a tedious process since it can be done internally if we try to create a C++ project which in turn installs required compiler and sets the environment.
    • One thing to note here is, check whether you have necessary C++ Redistributable.
  3. Oracle instant client for Windows
    • Download both Instant Client Package - Basic and Instant Client Package - SDK Link
    • Copy the contents in both zip files into C:\Oracle\instantclient.
    • Set System variables as explained earlier.Include the instantclient's location to PATH variable like PATH: C:\Oracle\instantclient.
    • Create a new variable with name as OCI_LIB_DIR and add value as C:\Oracle\instantclient\sdk\lib\msvc. OCI_LIB_DIR: C:\Oracle\instantclient\sdk\lib\msvc
    • Create a new variable with name as OCI_INC_DIR and add value as C:\Oracle\instantclient\sdk\include. OCI_INC_DIR: C:\Oracle\instantclient\sdk\include
  4. Run npm install oracle/node-oracledb.git#v2.3.0. This should suffice and tada oracledb node module installs into out working directory after binary compilation.
  5. don't forget to install github :-)

Issues faced

  1. NJS-045: cannot load the oracledb add-on binary for Node.js or DPI-1047: Oracle Client library cannot be loaded, then review any messages and the installation instructions. This error would be caused mainly due to dependency mismatch. All the versions must be under same architecture.
  2. On the hindsight, don't use 12c since it trims return text while retrieving from oracle

Top comments (0)