Skip to content

Instantly share code, notes, and snippets.

@kubo
Last active March 14, 2023 04:10
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kubo/aeabbbcd7b8cbda49531 to your computer and use it in GitHub Desktop.
Save kubo/aeabbbcd7b8cbda49531 to your computer and use it in GitHub Desktop.
Install node-oracledb on OS X 10.11 El Capitan

This document has been obsolete. Look at here instead.


The followings are obsolete.

This page is combination of node-oracledb document and ruby-oci8 document.

Some parts are copied from node-oracledb. Some parts are copied from ruby-oci8.

Install C compiler

You need to install the command line developer tools or the Xcode. (The latter includes the former.)

Run cc --version in a terminal to check whether they are installed.

If the cc version is printed, the tools are installed.

If this dialog is displayed, click its Install button to install the tools. You have no need to install the Xcode to compile node-oracledb. It requires command line tools, not an IDE such as the Xcode.

If Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo. is printed, you need to run sudo cc --version, enter your password, look at the license and type agree.

Install Node.js

Node.js can be installed from various sources, such as via brew.

brew install node
brew install homebrew/versions/node012 # install node 0.12.7

Don't use brew install node, which installs node 4.2. Node-oracledb 1.2 doesn't work with node 4.2.

Set your PATH to include the node and npm binaries:

export PATH=/usr/local/bin:$PATH

Install Oracle Instant Client Packages

Download Oracle Instant Client Packages

Download the following packages from Oracle Technology Network

  • Instant Client Package - Basic or Basic Lite
  • Instant Client Package - SDK
  • Instant Client Package - SQL*Plus (optionally)

Install Oracle Instant Client Packages via Homebrew

To install Oracle Instant Client Basic Lite via Homebrew

  • Download two instant client packages: Basic Lite and SDK and put them in /Library/Caches/Homebrew (if the environment variable HOMEBREW_CACHE is not set and $HOME/Library/Caches/Homebrew doesn't exist.)

  • Run the followining commands:

      brew install InstantClientTap/instantclient/instantclient-basiclite
      brew install InstantClientTap/instantclient/instantclient-sdk
    
  • Set the following environment variables while performing the following installation steps.

      export OCI_LIB_DIR=$(brew --prefix)/lib
      export OCI_INC_DIR=$(brew --prefix)/lib/sdk/include
    

To install Oracle Instant Client Basic via Homebrew

  • Download three instant client packages: Basic, Basic Lite and SDK and put them in /Library/Caches/Homebrew (if the environment variable HOMEBREW_CACHE is not set and $HOME/Library/Caches/Homebrew doesn't exist.)

  • Run the followining commands:

      brew install InstantClientTap/instantclient/instantclient-basic
      brew install InstantClientTap/instantclient/instantclient-sdk
    
  • Set the following environment variables while performing the following installation steps.

      export OCI_LIB_DIR=$(brew --prefix)/lib
      export OCI_INC_DIR=$(brew --prefix)/lib/sdk/include
    

Install Oracle Instant Client Manually

If you don't use Homebrew, do the following:

Unzip the packages as follows:

mkdir /opt
mkdir /opt/oracle
cd /opt/oracle

Copy downloaded files to /opt/oracle before running the following commands.

unzip instantclient-basic-macos.x64-11.2.0.4.0.zip
unzip instantclient-sdk-macos.x64-11.2.0.4.0.zip
unzip instantclient-sqlplus-macos.x64-11.2.0.4.0.zip

Make a symbolic link to link the library.

cd /opt/oracle/instantclient11_2
ln -s libclntsh.dylib.11.1 libclntsh.dylib

Fix the library install and identification names using fix_oralib to make them work without DYLD_LIBRARY_PATH.

cd /opt/oracle/instantclient11_2
curl -O https://raw.githubusercontent.com/kubo/fix_oralib_osx/master/fix_oralib.rb
ruby fix_oralib.rb --absolute-path

Set the following environment variables while performing the following installation steps.

export OCI_LIB_DIR=/opt/oracle/instantclient11_2
export OCI_INC_DIR=/opt/oracle/instantclient11_2/sdk/include

Install Node-Oracledb

If you are behind a firewall, you may need to set your proxy, for example:

npm config set https-proxy http://my-proxy.example.com:80

Install node-oracledb from the NPM registry:

npm install oracledb

If you are installing with sudo, you may need to use sudo -E to preserve the environment variable values.

@kriogenx0
Copy link

Your docs are incredibly hard to follow, which includes your fix_oralib. Can you please take more time to make each step a little more understandable? For example you're saying to download the packages and put them in the homebrew directory. Can you specify where to download so we make sure we're talking about the same packages? Can you tell which folder(s) to leave the packages in, or what they should be named?

@mm6396
Copy link

mm6396 commented Mar 14, 2023

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment