2020-06-30 08:40:57 +08:00
# Installing node-oracledb Version 5.1-dev
2015-01-21 00:51:22 +08:00
2020-02-16 07:49:02 +08:00
*Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.*
2015-01-21 00:51:22 +08:00
You may not use the identified files except in compliance with the Apache
License, Version 2.0 (the "License.")
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
2018-05-22 12:55:31 +08:00
## <a name="contents"></a> Contents
## ===> *** Note: Go to [https://oracle.github.io/node-oracledb/INSTALL.html](https://oracle.github.io/node-oracledb/INSTALL.html) for production documentation ***
2015-01-21 00:51:22 +08:00
2017-07-08 10:48:36 +08:00
1. [Node-oracledb Overview ](#overview )
2019-08-14 19:48:50 +08:00
2. [Quick Start node-oracledb Installation ](#quickstart )
2017-07-11 10:41:54 +08:00
3. [Node-oracledb Installation Instructions ](#instructions )
2018-02-21 07:53:15 +08:00
- 3.1 [Prerequisites ](#prerequisites )
2020-06-03 12:14:49 +08:00
- 3.2 [Node-oracledb Installation on Linux ](#linuxinstall )
- 3.2.1 [Node-oracledb Installation on Linux with Instant Client ZIP files ](#instzip )
- 3.2.2 [Node-oracledb Installation on Linux with a Local Database or Full Client ](#instoh )
- 3.2.3 [Node-oracledb Installation on Linux with Instant Client RPMs ](#instrpm )
- 3.2.4 [Installing Node.js and node-oracledb RPMs from yum.oracle.com ](#instnoderpms )
- 3.3 [Node-oracledb Installation on Apple macOS ](#instosx )
- 3.4 [Node-oracledb Installation on Microsoft Windows ](#windowsinstallation )
- 3.4.1 [Node-oracledb Installation on Microsoft Windows with Instant Client ZIP files ](#instwin )
- 3.4.2 [Node-oracledb Installation on Microsoft Windows with a Local Database or Full Client ](#instwinoh )
- 3.5 [Node-oracledb Installation on AIX on Power Systems with Instant Client ZIP files ](#instaix )
- 3.6 [Node-oracledb Installation on Oracle Solaris x86-64 (64-Bit) with Instant Client ZIP files ](#instsolarisx8664 )
- 3.7 [Node-oracledb Installation from Source Code ](#github )
- 3.7.1 [Environment for compiling from source code ](#compileenv )
- 3.7.2 [Installing GitHub clones and ZIP files ](#githubclone )
- 3.7.3 [Installing using GitHub branches and tags ](#githubtags )
- 3.7.4 [Installing from a source package ](#sourcepackage )
- 3.7.5 [Installing from Oracle's repository ](#nogithubaccess )
- 3.7.6 [Creating a node-oracledb package from source code ](#compilepackage )
- 3.8 [Node-oracledb Installation Without Internet Access ](#offline )
- 3.8.1 [Copying node-oracledb Binaries on Windows ](#winbins )
- 3.9 [Hosting your own node-oracledb Packages ](#selfhost )
- 3.10 [Using node-oracledb in Docker ](#docker )
2019-08-14 19:48:50 +08:00
4. [Installing Older Versions of Node-oracledb ](#installingoldvers )
5. [Troubleshooting Node-oracledb Installation Problems ](#troubleshooting )
2017-07-08 10:48:36 +08:00
## <a name="overview"></a> 1. Node-oracledb Overview
2015-01-21 00:51:22 +08:00
2020-06-03 12:14:49 +08:00
The [*node-oracledb*][4] add-on for Node.js powers high performance Oracle Database applications.
2015-05-05 01:07:26 +08:00
2015-03-29 07:48:19 +08:00
The steps below create a Node.js installation for testing. Adjust the
steps for your environment.
2015-01-21 00:51:22 +08:00
2020-06-13 05:23:59 +08:00
This node-oracledb release has been tested with Node.js 10, 12 and 14 on 64-bit
2020-06-25 07:38:09 +08:00
Oracle Linux, Windows and macOS. Note Node.js 10.16, or later is required. The
add-on can also build on some 32-bit Linux, 32-bit Windows, Solaris and AIX
environments, but these architectures have not been fully tested. Older
versions of node-oracledb may work with older versions of Node.js.
2015-01-21 00:51:22 +08:00
2020-02-28 07:50:42 +08:00
Node-oracledb requires Oracle Client libraries version 11.2 or later, and
2020-05-20 20:50:36 +08:00
can connect to Oracle Database 9.2 or later, depending on the Oracle Client library
2020-02-28 07:50:42 +08:00
version. The architecture is shown in [Node-oracledb Architecture][60].
2017-12-12 07:17:52 +08:00
Node-oracledb is an [add-on ](https://nodejs.org/api/addons.html )
2019-03-13 14:12:20 +08:00
available as C source code. Pre-built binaries are available
2017-12-12 07:17:52 +08:00
as a convenience for common architectures. Note the operating systems
and versions of Node.js that the pre-built binaries are compatible
with will change as the Node.js project evolves. The binaries are not
guaranteed to be available or usable in your environment.
2019-08-14 19:48:50 +08:00
## <a name="quickstart"></a> 2. Quick Start node-oracledb Installation
2017-11-17 20:06:47 +08:00
2017-12-12 07:17:52 +08:00
- Install Node.js from [nodejs.org][11].
2019-08-14 19:48:50 +08:00
- Install node-oracledb using the `npm` package manager, which is included in
Node.js. If you are behind a firewall, you may need to set the proxy with
`npm config set proxy http://myproxy.example.com:80/` .
2017-12-12 07:17:52 +08:00
- Many users will be able to use a pre-built node-oracledb binary:
2017-11-17 20:06:47 +08:00
2019-08-14 19:48:50 +08:00
- Add `oracledb` to your `package.json` dependencies or run `npm install
oracledb`. This installs from the [npm registry][4].
2017-11-17 20:06:47 +08:00
2019-07-25 13:00:30 +08:00
Windows users will require the [Visual Studio 2017
2017-12-12 07:17:52 +08:00
Redistributable][27].
2017-07-08 10:48:36 +08:00
2017-12-12 07:17:52 +08:00
- If a binary is not available, you will need to compile node-oracledb
2019-03-13 14:12:20 +08:00
from source code:
2017-07-08 10:48:36 +08:00
2020-05-20 20:50:36 +08:00
- Install [Python 2.7][2] (Note: recent Node.js tools should work with Python 3).
2017-11-17 20:06:47 +08:00
2019-03-13 14:12:20 +08:00
- Install a C Compiler such as Xcode, GCC, Visual Studio
2019-07-25 13:00:30 +08:00
2017, or similar.
2017-07-08 10:48:36 +08:00
2020-06-30 08:40:57 +08:00
- Run `npm install oracle/node-oracledb.git#v5.1.0` , or add
`oracle/node-oracledb.git#v5.1.0` to your `package.json`
2017-12-12 07:17:52 +08:00
dependencies. Substitute your desired [GitHub tag][40].
2017-07-08 10:48:36 +08:00
2019-03-13 14:12:20 +08:00
- Add Oracle 19, 18, 12, or 11.2 client libraries to your operating
2017-12-12 07:17:52 +08:00
system library search path such as `PATH` on Windows or
2020-05-20 20:50:36 +08:00
`LD_LIBRARY_PATH` on Linux. On macOS link the libraries to
`/usr/local/lib` .
2017-07-08 10:48:36 +08:00
2017-12-12 07:17:52 +08:00
- If your database is remote, then get the libraries by
downloading and unzipping the free [Oracle Instant Client][3]
"Basic" or "Basic Light" package for your operating system
architecture.
2017-07-08 10:48:36 +08:00
2017-12-12 07:17:52 +08:00
Instant Client on Windows requires an appropriate [Visual Studio
2020-06-03 12:09:34 +08:00
Redistributable](#winredists). On Linux, the `libaio` (sometimes called
`libaio1` ) package is needed. On recent Linux versions, such as Oracle
Linux 8, you may also need to install the `libnsl` package.
2017-12-12 07:17:52 +08:00
- Alternatively use the Oracle Client libraries already available
in `$ORACLE_HOME/lib` from a locally installed database such as
the free [Oracle XE][20] release.
2019-03-13 14:12:20 +08:00
Oracle Client libraries 19, 18 and 12.2 can connect to Oracle
Database 11.2 or greater. Version 12.1 client libraries can connect
to Oracle Database 10.2 or greater. Version 11.2 client libraries
can connect to Oracle Database 9.2 or greater.
2017-06-14 09:49:08 +08:00
2018-02-06 10:58:09 +08:00
- Your Node.js applications can now connect to your database. The
database can be on the same machine as Node.js, or on a remote
machine. Node-oracledb does not install or create a database.
You will need to know [database credentials][45] and the [connection
string][7] for the database.
2015-01-21 00:51:22 +08:00
2017-12-12 07:17:52 +08:00
After installation, learn how to use node-oracledb from the
[examples][19] and the [documentation][44].
2018-02-06 10:58:09 +08:00
See [Troubleshooting Node-oracledb Installation
Problems](#troubleshooting) if you have installation issues.
2017-12-12 06:56:12 +08:00
## <a name="instructions"></a> 3. Node-oracledb Installation Instructions
2017-07-08 10:48:36 +08:00
2017-11-17 20:06:47 +08:00
Instructions may need to be adjusted for your platform, environment and versions being used.
2017-07-08 10:48:36 +08:00
2017-11-17 20:06:47 +08:00
I have ... | Follow this ...
----------|-----------------
2020-06-03 12:14:49 +08:00
Windows. My database is on another machine | [Node-oracledb Installation on Microsoft Windows with Instant Client ZIP files ](#instwin )
Windows. My database is on the same machine as Node.js | [Node-oracledb Installation on Microsoft Windows with a Local Database or Full Client ](#instwinoh )
Apple macOS | [Node-oracledb Installation on Apple macOS ](#instosx )
2019-03-21 05:09:33 +08:00
Linux that uses RPM packages. My database is on another machine | [Node-oracledb Installation on Linux with Instant Client RPMs ](#instrpm )
Linux that uses Debian packages. My database is on another machine | [Node-oracledb Installation on Linux with Instant Client ZIP files ](#instzip )
2017-11-17 20:06:47 +08:00
Linux. My database is on the same machine as Node.js | [Node-oracledb Installation on Linux with a Local Database or Full Client ](#instoh )
Linux. I have the full Oracle client (installed via `runInstaller` ) on the same machine as Node.js | [Node-oracledb Installation on Linux with a Local Database or Full Client ](#instoh )
2020-02-16 08:16:59 +08:00
Linux. I want to install Node.js and node-oracledb RPM packages | [Installing Node.js and node-oracledb RPMs from yum.oracle.com ](#instnoderpms )
2017-11-17 20:06:47 +08:00
AIX on Power Systems | [Node-oracledb Installation on AIX on Power Systems with Instant Client ZIP files ](#instaix )
Solaris x86-64 (64-Bit) | [Node-oracledb Installation on Oracle Solaris x86-64 (64-Bit) with Instant Client ZIP files ](#instsolarisx8664 )
2019-08-14 19:48:50 +08:00
Another OS with Oracle Database 19, 18, 12, or 11.2 client libraries available | Update binding.gyp and make any code changes required, sign the [OCA][8], and submit a pull request with your patch.
2017-12-12 07:17:52 +08:00
Source code from GitHub | [Node-oracledb Installation from Source Code ](#github )
2017-11-17 20:06:47 +08:00
I don't have internet access | [Node-oracledb Installation Without Internet Access ](#offline )
2017-07-08 10:48:36 +08:00
2017-12-12 06:56:12 +08:00
### <a name="prerequisites"></a> 3.1 Prerequisites
2017-11-17 20:06:47 +08:00
All installations need:
2017-07-08 10:48:36 +08:00
2020-02-16 07:49:02 +08:00
- Oracle 19, 18, 12 or 11.2 client libraries on the machine Node.js is installed on.
2017-07-08 10:48:36 +08:00
2017-12-12 07:17:52 +08:00
Run `node -p "process.arch"` and make sure to use 64-bit or 32-bit
Oracle client libraries to match the Node.js architecture.
2017-11-17 20:06:47 +08:00
Oracle client libraries are included in [Oracle Instant Client][3]
RPMs or ZIPs, a full Oracle Client, or a database on the same
machine. You only need one of these installations.
2017-07-08 10:48:36 +08:00
2017-12-12 07:17:52 +08:00
Oracle's standard client-server network interoperability allows
connections between different versions of Oracle Client and Oracle
Database. For certified configurations see Oracle Support's [Doc ID
2019-03-13 14:12:20 +08:00
207303.1][6]. In summary, Oracle Client 19, 18 and 12.2 can connect
to Oracle Database 11.2 or greater. Oracle Client 12.1 can connect
to Oracle Database 10.2 or greater. Oracle Client 11.2 can connect
to Oracle Database 9.2 or greater. The technical restrictions on
creating connections may be more flexible. For example Oracle
Client 12.2 can successfully connect to Oracle Database 10.2.
2017-07-08 10:48:36 +08:00
- An Oracle Database to test node-oracledb.
After installation of node-oracledb, your Node.js applications will
be able to connect to your database. The database can be on the
2018-02-06 10:35:23 +08:00
same machine as Node.js, or on a remote machine. Node-oracledb does
not install or create a database.
2017-07-08 10:48:36 +08:00
2018-02-06 10:58:09 +08:00
You will need to know [database credentials][45] and the [connection
2017-11-17 20:06:47 +08:00
string][7] for the database.
2015-01-21 00:51:22 +08:00
2017-11-17 20:06:47 +08:00
If pre-built binaries are not available or desired, you need these
additional tools to build from source code:
2015-01-21 00:51:22 +08:00
2017-11-17 20:06:47 +08:00
- A compiler.
2015-01-21 00:51:22 +08:00
2017-11-17 20:06:47 +08:00
Use Visual Studio on Windows, GCC on Linux or Xcode on macOS.
2015-01-21 00:51:22 +08:00
2020-06-03 12:14:49 +08:00
- [Python 2.7][2] is needed by node-gyp, which is invoked by npm. Run `python
--version` to find the version you have. (Note: recent Node.js tools should
work with Python 3).
2015-01-21 00:51:22 +08:00
2017-11-17 20:06:47 +08:00
If another version of Python occurs first in your binary path then,
2017-12-12 06:48:37 +08:00
when you install node-oracledb, then run `npm config set python
/wherever/python-2.7/bin/python` or use the `--python` option to
2017-11-17 20:06:47 +08:00
indicate the correct version. For example: `npm install
--python=/wherever/python-2.7/bin/python oracledb`.
2017-06-14 09:49:08 +08:00
2020-06-03 12:14:49 +08:00
#### <a name="linuxinstall"></a> 3.2 Node-oracledb Installation on Linux
2015-01-21 00:51:22 +08:00
2020-06-03 12:14:49 +08:00
There are four ways to install node-oracledb on Linux:
- [Node-oracledb Installation on Linux with Instant Client ZIP files ](#instzip )
- [Node-oracledb Installation on Linux with a Local Database or Full Client ](#instoh )
- [Node-oracledb Installation on Linux with Instant Client RPMs ](#instrpm )
- [Installing Node.js and node-oracledb RPMs from yum.oracle.com ](#instnoderpms )
#### <a name="instzip"></a> 3.2.1 Node-oracledb Installation on Linux with Instant Client ZIP files
Follow these steps if your database is on a remote machine and either:
- you prefer installing Instant Client ZIP files instead of RPM packages
- or your Linux distribution uses the Debian package format, for example if you are using Ubuntu. Note: you should review Oracle's supported distributions before choosing an operating system.
2015-01-21 00:51:22 +08:00
2017-11-17 20:06:47 +08:00
Questions and issues can be posted as [GitHub Issues][10].
2015-01-21 00:51:22 +08:00
2020-06-03 12:14:49 +08:00
##### 3.2.1.1 Install Prerequisites
2017-06-14 09:49:08 +08:00
2017-11-17 20:06:47 +08:00
Review the generic [prerequisites ](#prerequisites ).
2017-06-14 09:49:08 +08:00
2017-12-12 06:56:12 +08:00
Pre-built binaries were built on Oracle Linux 6 and will require a
compatible glibc.
2020-06-03 12:14:49 +08:00
##### 3.2.1.2 Install Node.js
2017-06-14 09:49:08 +08:00
2017-11-17 20:06:47 +08:00
Download and extract the [Node.js "Linux Binaries"][11] package. For
2020-02-16 07:49:02 +08:00
example, if you downloaded version 12.14.1 for 64-bit you could install
2017-11-17 20:06:47 +08:00
Node.js into `/opt` :
2015-01-21 00:51:22 +08:00
```
2017-06-14 09:49:08 +08:00
cd /opt
2020-02-16 07:49:02 +08:00
tar -Jxf node-v12.14.1-linux-x64.tar.xz
2015-01-21 00:51:22 +08:00
```
2017-06-19 07:11:17 +08:00
Set `PATH` to include Node.js:
2015-01-21 00:51:22 +08:00
2017-06-14 09:49:08 +08:00
```
2020-02-16 07:49:02 +08:00
export PATH=/opt/node-v12.14.1-linux-x64/bin:$PATH
2017-06-14 09:49:08 +08:00
```
2020-06-03 12:14:49 +08:00
##### 3.2.1.3 Install node-oracledb
2015-01-21 00:51:22 +08:00
2015-12-21 20:11:15 +08:00
If you are behind a firewall you may need to set your proxy, for
2015-07-20 15:57:32 +08:00
example:
```
2019-08-14 19:48:50 +08:00
npm config set proxy http://myproxy.example.com:80/
2015-11-15 06:03:27 +08:00
```
2018-02-06 10:10:04 +08:00
Install node-oracledb using the `npm` package manager, which is
included in Node.js:
2015-11-15 06:03:27 +08:00
```
2017-06-14 09:49:08 +08:00
npm install oracledb
2015-07-20 15:57:32 +08:00
```
2019-01-15 05:14:43 +08:00
The pre-built binaries were built on Oracle Linux 6.
2017-11-17 20:06:47 +08:00
2020-02-28 07:50:42 +08:00
If a pre-built node-oracledb binary is not installable or depends on an newer
glibc version, uninstall node-oracledb and build the binary from source code,
see [Node-oracledb Installation from Source Code ](#github ).
2017-06-14 09:49:08 +08:00
2020-06-03 12:14:49 +08:00
##### 3.2.1.4 Install the free Oracle Instant Client 'Basic' ZIP file
2018-12-23 06:52:34 +08:00
2020-06-03 12:14:49 +08:00
Download the free **Basic** ZIP file from [Oracle Technology Network][12]
and [unzip it][13] into a directory accessible to your application,
for example:
2019-07-02 10:35:56 +08:00
```
2020-06-03 12:14:49 +08:00
mkdir -p /opt/oracle
cd /opt/oracle
wget https://download.oracle.com/otn_software/linux/instantclient/instantclient-basic-linuxx64.zip
unzip instantclient-basic-linuxx64.zip
2019-07-02 10:35:56 +08:00
```
2020-06-03 12:14:49 +08:00
You will need the operating system `libaio` package installed. On some
platforms the package is called `libaio1` . Run a command like `yum install -y
libaio` or `apt-get install -y libaio1` , depending on your Linux distribution
package manager. On recent Linux versions, such as Oracle Linux 8, you may also
need to install the `libnsl` package. Oracle Instant Client 19 will not run on
Oracle Linux 6.
If there is no other Oracle software on the machine that will be impacted, then
permanently add Instant Client to the run-time link path. For example, if the
Basic package unzipped to `/opt/oracle/instantclient_19_6` , then run the
following using sudo or as the root user:
2015-01-21 00:51:22 +08:00
```
2020-06-03 12:14:49 +08:00
sudo sh -c "echo /opt/oracle/instantclient_19_6 > /etc/ld.so.conf.d/oracle-instantclient.conf"
sudo ldconfig
2015-01-21 00:51:22 +08:00
```
2020-06-03 12:14:49 +08:00
Alternatively, every shell running Node.js will need to have the link
path set:
2015-11-15 06:13:44 +08:00
2017-06-14 09:49:08 +08:00
```
2020-06-03 12:14:49 +08:00
export LD_LIBRARY_PATH=/opt/oracle/instantclient_19_6:$LD_LIBRARY_PATH
2017-06-14 09:49:08 +08:00
```
2020-06-03 12:14:49 +08:00
If disk space is important, most users will be able to use the smaller Basic
Light package instead of the Basic package. Review its [globalization
limitations][62]. Disk space can be reduced by removing unnecessary libraries
and files from either the Basic or Basic Light packages. The exact libraries
depend on the Instant Client version. For example, with Oracle Instant Client
19, you can optionally remove files using:
2017-06-14 09:49:08 +08:00
```
2020-06-03 12:14:49 +08:00
rm -i *jdbc* *occi* *mysql* *mql1* *ipc1* *jar uidrvci genezi adrci
2017-06-14 09:49:08 +08:00
```
2020-06-03 12:14:49 +08:00
Refer to the Oracle Instant Client documentation for details.
##### 3.2.1.5 Optionally create the Oracle Client configuration directory
2017-11-17 20:06:47 +08:00
2020-06-03 12:14:49 +08:00
If you use optional Oracle configuration files such as `tnsnames.ora` ,
`sqlnet.ora` or `oraaccess.xml` with Instant Client, then put the files in an
accessible directory, for example in `/opt/oracle/your_config_dir` . Then use
the [`oracledb.initOracleClient()`][64] in your application:
2017-11-17 20:06:47 +08:00
2020-06-03 12:14:49 +08:00
```javascript
const oracledb = require('oracledb');
oracledb.initOracleClient({configDir: '/opt/oracle/your_config_dir'});
2017-11-17 20:06:47 +08:00
```
2020-06-03 12:14:49 +08:00
Or you can set the environment variable `TNS_ADMIN` to that directory name.
2017-11-17 20:06:47 +08:00
2020-06-03 12:14:49 +08:00
Another alternative is to put the files in the `network/admin` subdirectory of
Instant Client, for example in `/opt/oracle/instantclient_19_6/network/admin` .
This is the default Oracle configuration directory for executables linked with
this Instant Client.
2015-01-21 00:51:22 +08:00
2020-06-03 12:14:49 +08:00
##### 3.2.1.6 Run an example program
2017-11-17 20:06:47 +08:00
Download the [example programs][19] from GitHub.
2015-01-21 00:51:22 +08:00
2018-02-06 10:39:51 +08:00
Edit `dbconfig.js` and set the [database credentials][45] to your
2017-06-14 09:49:08 +08:00
environment, for example:
2015-01-21 00:51:22 +08:00
```
module.exports = {
user : "hr",
2019-02-08 09:55:21 +08:00
password : process.env.NODE_ORACLEDB_PASSWORD,
2019-01-11 05:54:53 +08:00
connectString : "localhost/XEPDB1"
2015-01-21 00:51:22 +08:00
};
```
2020-06-03 12:14:49 +08:00
Run one of the examples, such as [`example.js`][63]:
2015-01-21 00:51:22 +08:00
```
2018-09-26 16:02:52 +08:00
node example.js
2015-01-21 00:51:22 +08:00
```
2017-06-14 09:49:08 +08:00
*Note:* Remember to set `LD_LIBRARY_PATH` or equivalent first.
2015-01-21 00:51:22 +08:00
2020-06-03 12:14:49 +08:00
#### <a name="instoh"></a> 3.2.2 Node-oracledb installation on Linux with a Local Database or Full Client
2017-06-14 09:49:08 +08:00
2017-11-17 20:06:47 +08:00
Questions and issues can be posted as [GitHub Issues][10].
2017-06-14 09:49:08 +08:00
2020-06-03 12:14:49 +08:00
##### 3.2.2.1 Install Prerequisites
2017-06-14 09:49:08 +08:00
2017-11-17 20:06:47 +08:00
Review the generic [prerequisites ](#prerequisites ).
2017-06-14 09:49:08 +08:00
2020-06-03 12:14:49 +08:00
The `ORACLE_HOME` can be either a database home or a full Oracle
client installation installed with Oracle's `runInstaller` .
2017-12-12 06:56:12 +08:00
2020-06-03 12:14:49 +08:00
For easy development, the free [Oracle XE][20] version of the database
is available on Linux. Applications developed with XE may be
immediately used with other editions of the Oracle Database.
##### 3.2.2.2 Install Node.js
2017-11-17 20:06:47 +08:00
Download and extract the [Node.js "Linux Binaries"][11] package. For
2020-02-16 07:49:02 +08:00
example, if you downloaded version 12.14.1 for 64-bit you could install
2017-11-17 20:06:47 +08:00
Node.js into `/opt` :
2015-01-21 00:51:22 +08:00
```
2015-03-29 07:48:19 +08:00
cd /opt
2020-06-03 12:14:49 +08:00
tar -zxf node-v12.14.1-linux-x64.tar.gz
2015-01-21 00:51:22 +08:00
```
2017-06-19 07:11:17 +08:00
Set `PATH` to include Node.js:
2015-01-21 00:51:22 +08:00
```
2020-02-16 07:49:02 +08:00
export PATH=/opt/node-v12.14.1-linux-x64/bin:$PATH
2015-01-21 00:51:22 +08:00
```
2020-06-03 12:14:49 +08:00
##### 3.2.2.3 Install node-oracledb
2015-01-21 00:51:22 +08:00
2017-06-14 09:49:08 +08:00
If you are behind a firewall you may need to set your proxy, for
example:
2015-01-21 00:51:22 +08:00
```
2019-08-14 19:48:50 +08:00
npm config set proxy http://myproxy.example.com:80/
2015-01-21 00:51:22 +08:00
```
2018-02-06 10:10:04 +08:00
Install node-oracledb using the `npm` package manager, which is
included in Node.js:
2015-01-21 00:51:22 +08:00
```
2017-06-14 09:49:08 +08:00
npm install oracledb
2015-01-21 00:51:22 +08:00
```
2020-06-03 12:14:49 +08:00
If a pre-built binary is successfully installed but isn't usable
because it depends on a different glibc version, uninstall
node-oracledb and install again from source code.
2015-01-21 00:51:22 +08:00
2020-06-03 12:14:49 +08:00
If a pre-built node-oracledb binary is not installable, the binary can
be built from source code, see [Node-oracledb Installation from
Source Code](#github).
2015-11-15 06:03:27 +08:00
2020-06-03 12:14:49 +08:00
##### 3.2.2.4 The default Oracle Client configuration directory
2017-11-17 20:06:47 +08:00
2020-06-03 12:14:49 +08:00
Optional Oracle client configuration files such as [`tnsnames.ora`][15],
[`sqlnet.ora`][16], and [`oraaccess.xml`][18] can be placed in
`$ORACLE_HOME/network/admin` .
2017-11-17 20:06:47 +08:00
2020-06-03 12:14:49 +08:00
Alternatively, if you use Oracle client configuration files, they can be put in
another, accessible directory. Then use `oracledb.initOracleClient({configDir:
'/your_path/your_config_dir'});` or set the environment variable `TNS_ADMIN` to
that directory name.
2015-11-15 06:03:27 +08:00
2020-06-03 12:14:49 +08:00
##### 3.2.2.5 Run an example program
2015-07-20 15:57:32 +08:00
2020-06-03 12:14:49 +08:00
Set required Oracle environment variables, such as `ORACLE_HOME` and
`LD_LIBRARY_PATH` by executing:
2020-06-03 12:12:53 +08:00
```
2020-06-03 12:14:49 +08:00
source /usr/local/bin/oraenv
2020-06-03 12:12:53 +08:00
```
2020-06-03 12:14:49 +08:00
Or, if you are using Oracle XE 11.2, by executing:
2015-01-21 00:51:22 +08:00
```
2020-06-03 12:14:49 +08:00
source /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh
2015-01-21 00:51:22 +08:00
```
2020-06-03 12:14:49 +08:00
Make sure the Node.js process has directory and file access
permissions for the Oracle libraries and other files. Typically the
home directory of the Oracle software owner will need permissions
relaxed.
2015-03-29 07:48:19 +08:00
2017-11-17 20:06:47 +08:00
Download the [example programs][19] from GitHub.
2015-03-29 07:48:19 +08:00
2018-02-06 10:39:51 +08:00
Edit `dbconfig.js` and set the [database credentials][45] to your
2017-06-14 09:49:08 +08:00
environment, for example:
2015-01-21 00:51:22 +08:00
```
module.exports = {
user : "hr",
2019-02-08 09:55:21 +08:00
password : process.env.NODE_ORACLEDB_PASSWORD,
2019-01-11 05:54:53 +08:00
connectString : "localhost/XEPDB1"
2015-01-21 00:51:22 +08:00
};
```
2020-06-03 12:14:49 +08:00
Run one of the examples, such as [`example.js`][63]:
2015-01-21 00:51:22 +08:00
```
2018-09-26 16:02:52 +08:00
node example.js
2015-01-21 00:51:22 +08:00
```
2020-06-03 12:14:49 +08:00
#### <a name="instrpm"></a> 3.2.3 Node-oracledb Installation on Linux with Instant Client RPMs
2015-01-21 00:51:22 +08:00
2020-06-03 12:14:49 +08:00
Follow these steps if your database is on a remote machine and your
Linux distribution uses RPM packages. Also see [Installing Node.js and
node-oracledb RPMs from yum.oracle.com](#instnoderpms).
2015-01-21 00:51:22 +08:00
2017-11-17 20:06:47 +08:00
Questions and issues can be posted as [GitHub Issues][10].
2017-06-14 09:49:08 +08:00
2020-06-03 12:14:49 +08:00
##### 3.2.3.1 Install Prerequisites
2017-06-14 09:49:08 +08:00
2017-11-17 20:06:47 +08:00
Review the generic [prerequisites ](#prerequisites ).
2017-06-14 09:49:08 +08:00
2020-06-03 12:14:49 +08:00
Pre-built binaries were built on Oracle Linux 6 and will require a
compatible glibc.
2017-11-17 20:06:47 +08:00
2020-06-03 12:14:49 +08:00
##### 3.2.3.2 Install Node.js
2017-11-17 20:06:47 +08:00
Download and extract the [Node.js "Linux Binaries"][11] package. For
2020-02-16 07:49:02 +08:00
example, if you downloaded version 12.14.1 for 64-bit you could install
2017-11-17 20:06:47 +08:00
Node.js into `/opt` :
2015-01-21 00:51:22 +08:00
```
2015-03-29 07:48:19 +08:00
cd /opt
2020-06-03 12:14:49 +08:00
tar -Jxf node-v12.14.1-linux-x64.tar.xz
2015-01-21 00:51:22 +08:00
```
2017-06-19 07:11:17 +08:00
Set `PATH` to include Node.js:
2015-01-21 00:51:22 +08:00
```
2020-02-16 07:49:02 +08:00
export PATH=/opt/node-v12.14.1-linux-x64/bin:$PATH
2015-01-21 00:51:22 +08:00
```
2020-06-03 12:14:49 +08:00
##### 3.2.3.3 Install node-oracledb
2015-01-21 00:51:22 +08:00
2017-06-14 09:49:08 +08:00
If you are behind a firewall you may need to set your proxy, for
example:
2015-01-21 00:51:22 +08:00
```
2019-08-14 19:48:50 +08:00
npm config set proxy http://myproxy.example.com:80/
2015-01-21 00:51:22 +08:00
```
2018-02-06 10:10:04 +08:00
Install node-oracledb using the `npm` package manager, which is
included in Node.js:
2015-07-20 15:57:32 +08:00
```
2017-06-14 09:49:08 +08:00
npm install oracledb
2015-11-15 06:03:27 +08:00
```
2020-06-03 12:14:49 +08:00
The pre-built binaries were built on Oracle Linux 6.
2017-06-14 09:49:08 +08:00
2020-06-03 12:14:49 +08:00
If a pre-built node-oracledb binary is not installable or depends on an newer
glibc version, uninstall node-oracledb and build the binary from source code,
see [Node-oracledb Installation from Source Code ](#github ).
2017-11-17 20:06:47 +08:00
2020-06-03 12:14:49 +08:00
##### 3.2.3.4 Install the free Oracle Instant Client 'Basic' RPM
2017-11-17 20:06:47 +08:00
2020-06-03 12:14:49 +08:00
Download the latest version of the free **Basic** RPM from yum.oracle.com.
There are channels for [Oracle Linux 6][50] and [Oracle Linux 7][51]. The
package contents are identical in both channels. The RPMs are also available
from [Oracle Technology Network][12].
2017-11-17 20:06:47 +08:00
2020-06-03 12:14:49 +08:00
[Install Instant Client Basic][13] with sudo or as the root user. You can
install directly from yum.oracle.com, for example using:
2017-11-17 20:06:47 +08:00
2020-06-03 12:14:49 +08:00
```
sudo yum -y install oracle-release-el7
sudo yum-config-manager --enable ol7_oracle_instantclient
sudo yum -y install oracle-instantclient19.6-basic
```
2017-11-17 20:06:47 +08:00
2020-06-03 12:14:49 +08:00
Alternatively you can manually download the RPM and install from your local file
system:
2015-01-21 00:51:22 +08:00
```
2020-06-03 12:14:49 +08:00
sudo yum install oracle-instantclient19.6-basic-19.6.0.0.0-1.x86_64.rpm
2015-01-21 00:51:22 +08:00
```
2020-06-03 12:14:49 +08:00
The link [instantclient-basic-linuxx64.zip][61] will download the latest version
available from [OTN][12].
If you have a [ULN][14] subscription, another alternative is to use `yum` to
install the Basic package after enabling the ol7_x86_64_instantclient or
ol6_x86_64_instantclient channel, depending on your version of Linux.
Using any of these methods will install the required `libaio` package, if it is
not already present. On recent Linux versions, such as Oracle Linux 8, you may
also need to manually install the `libnsl` package. Oracle Instant Client 19
will not run on Oracle Linux 6.
For Instant Client 19 RPMs, the system library search path is automatically
configured during installation. For older versions, if there is no other Oracle
software on the machine that will be impacted, then permanently add Instant
Client to the run-time link path. For example, with sudo or as the root user:
2015-05-05 01:07:26 +08:00
2017-06-14 09:49:08 +08:00
```
2020-06-03 12:14:49 +08:00
sudo sh -c "echo /usr/lib/oracle/18.3/client64/lib > /etc/ld.so.conf.d/oracle-instantclient.conf"
sudo ldconfig
2017-06-14 09:49:08 +08:00
```
2015-01-21 00:51:22 +08:00
2020-06-03 12:14:49 +08:00
Alternatively, for version 18 and earlier, every shell running Node.js
will need to have the link path set:
```
export LD_LIBRARY_PATH=/usr/lib/oracle/18.3/client64/lib
```
##### 3.2.3.5 Optionally create the Oracle Client configuration directory
If you use optional Oracle configuration files such as `tnsnames.ora` ,
`sqlnet.ora` or `oraaccess.xml` with Instant Client, then put the files in an
accessible directory, for example in `/opt/oracle/your_config_dir` . Then use
[`oracledb.initOracleClient()`][64] in your application:
```javascript
const oracledb = require('oracledb');
oracledb.initOracleClient({configDir: '/opt/oracle/your_config_dir'});
```
Or you can set the environment variable `TNS_ADMIN` to that directory name.
Another alternative is to put the files in the `network/admin` subdirectory of
Instant Client, for example in
`/usr/lib/oracle/19.6/client64/lib/network/admin` . This is the default Oracle
configuration directory for executables linked with this Instant Client.
##### 3.2.3.6 Run an example program
2015-01-25 02:39:57 +08:00
2017-11-17 20:06:47 +08:00
Download the [example programs][19] from GitHub.
2015-03-29 07:48:19 +08:00
2018-02-06 10:39:51 +08:00
Edit `dbconfig.js` and set the [database credentials][45] to your
2017-06-14 09:49:08 +08:00
environment, for example:
2015-01-21 00:51:22 +08:00
```
module.exports = {
user : "hr",
2019-02-08 09:55:21 +08:00
password : process.env.NODE_ORACLEDB_PASSWORD,
2019-01-11 05:54:53 +08:00
connectString : "localhost/XEPDB1"
2015-01-21 00:51:22 +08:00
};
```
2020-06-03 12:14:49 +08:00
Run one of the examples, such as [`example.js`][63]:
2015-01-21 00:51:22 +08:00
```
2018-09-26 16:02:52 +08:00
node example.js
2015-01-21 00:51:22 +08:00
```
2015-03-29 07:48:19 +08:00
2020-06-03 12:14:49 +08:00
*Note:* Remember to set `LD_LIBRARY_PATH` or equivalent first.
#### <a name="instnoderpms"></a> 3.2.4 Installing Node.js and node-oracledb RPMs from yum.oracle.com
Node.js and node-oracledb Linux RPM packages are available on
[yum.oracle.com][46]. Oracle Instant Client is also available in
[Oracle Linux 6][50] and [Oracle Linux 7][51] channels. This means
installation is simple, and can be automated.
As an example, to install Node 10 on Oracle Linux 7, run these commands:
```
sudo yum install -y oracle-nodejs-release-el7 oracle-release-el7
sudo yum install nodejs node-oracledb-node10
```
For Instant Client 19, the system library search path is automatically
configured during installation.
For older versions, if there is no other Oracle software on the
machine that will be impacted, then permanently add Instant Client to
the run-time link path. For example, with sudo or as the root user:
```
sudo sh -c "echo /usr/lib/oracle/18.3/client64/lib > /etc/ld.so.conf.d/oracle-instantclient.conf"
sudo ldconfig
```
Since node-oracledb is installed globally, set `NODE_PATH` before
running applications:
```
export NODE_PATH=$(npm root -g)
node myapp.js
```
See [Node.js for Oracle Linux][46] for details.
### <a name="instosx"></a> 3.3 Node-oracledb Installation on Apple macOS
2015-02-12 07:14:30 +08:00
2017-11-17 20:06:47 +08:00
Questions and issues can be posted as [GitHub Issues][10].
2015-02-12 07:14:30 +08:00
2020-06-03 12:14:49 +08:00
#### 3.3.1 Install Prerequisites
2015-02-12 07:14:30 +08:00
2017-11-17 20:06:47 +08:00
Review the generic [prerequisites ](#prerequisites ).
2015-02-12 07:14:30 +08:00
2020-06-25 07:38:09 +08:00
The pre-built binaries were built on macOS Mojave 10.14.6.
2017-12-12 06:56:12 +08:00
2020-05-20 20:50:36 +08:00
Oracle Instant Client libraries are required on macOS. Note that Oracle Instant
2020-06-18 07:02:25 +08:00
Client 19c and earlier are not supported on macOS Catalina 10.15: you will need
to allow access to several Instant Client libraries from the Security & Privacy
preference pane.
2020-05-20 20:50:36 +08:00
There is no native Oracle Database for macOS but one can easily be run in a
Linux virtual machine, see [The Easiest Way to Install Oracle Database on Apple
macOS][21].
2016-01-25 19:12:08 +08:00
2020-06-03 12:14:49 +08:00
#### 3.3.2 Install Node.js
2017-11-17 20:06:47 +08:00
Download the [Node.js package][11] for macOS 64-bit and install it.
2020-06-03 12:14:49 +08:00
#### 3.3.3 Install node-oracledb
2016-01-25 19:12:08 +08:00
2017-06-14 09:49:08 +08:00
If you are behind a firewall you may need to set your proxy, for
example:
2016-01-25 19:12:08 +08:00
```
2019-08-14 19:48:50 +08:00
npm config set proxy http://myproxy.example.com:80/
2016-01-25 19:12:08 +08:00
```
2018-02-06 10:10:04 +08:00
Install node-oracledb using the `npm` package manager, which is
included in Node.js:
2016-01-25 19:12:08 +08:00
```
2017-06-14 09:49:08 +08:00
npm install oracledb
2016-01-25 19:12:08 +08:00
```
2017-11-17 20:06:47 +08:00
If a pre-built node-oracledb binary is not installable, the binary can
2017-12-12 07:17:52 +08:00
be built from source code, see [Node-oracledb Installation from
Source Code](#github).
2017-11-17 20:06:47 +08:00
2020-06-03 12:14:49 +08:00
#### 3.3.4 Install the free Oracle Instant Client 'Basic' ZIP file
2017-11-17 20:06:47 +08:00
2020-03-05 12:30:02 +08:00
Download the free **Basic** 64-bit ZIP from [Oracle Technology Network][22] and
2020-06-03 12:14:49 +08:00
unzip it. For example in Terminal you could unzip in your home directory:
2016-05-16 07:21:56 +08:00
```
2020-03-05 12:30:02 +08:00
cd ~
unzip instantclient-basic-macos.x64-19.3.0.0.0dbru.zip
2016-05-16 07:21:56 +08:00
```
2020-06-03 12:14:49 +08:00
There are several alternative ways to tell node-oracledb where your Oracle
Client libraries are, see [Initializing Node-oracledb][17]:
2016-05-16 07:21:56 +08:00
2020-06-03 12:14:49 +08:00
- Use [`oracledb.initOracleClient()`][64] in your application:
2020-03-05 12:30:02 +08:00
2020-06-03 12:14:49 +08:00
```javascript
const oracledb = require('oracledb');
try {
oracledb.initOracleClient({libDir: '/Users/your_username/instantclient_19_3'});
} catch (err) {
console.error('Whoops!');
console.error(err);
process.exit(1);
}
```
2020-03-05 12:30:02 +08:00
2020-06-03 12:14:49 +08:00
- Alternatively, create a symbolic link for the 'client shared library' in the
`node_modules/oracledb/build/Release` directory where the `oracledb*.node`
binary is. For example:
2015-11-15 06:03:27 +08:00
2020-06-03 12:14:49 +08:00
```
ln -s ~/instantclient_19_3/libclntsh.dylib node_modules/oracledb/build/Release
```
2015-07-20 15:57:32 +08:00
2020-06-03 12:14:49 +08:00
Instead of linking, you can also copy all the required OCI libraries, for example:
2015-02-12 07:14:30 +08:00
2020-06-03 12:14:49 +08:00
```
cp ~/instantclient_19_3/{libclntsh.dylib.19.1,libclntshcore.dylib.19.1,libnnz19.dylib,libociei.dylib} node_modules/oracledb/build/Release
cd node_modules/oracledb/build/Release/ & & ln -s libclntsh.dylib.19.1 libclntsh.dylib
```
2015-02-12 07:14:30 +08:00
2020-06-25 15:44:29 +08:00
- Alternatively, set `DYLD_LIBRARY_PATH` to include the Oracle Instant Client
directory. Note this variable must be set in the terminal or shell that
directly invokes Node.js. The variable will not propagate to sub-shells.
2020-06-03 12:14:49 +08:00
- Alternatively, create a symbolic link for the 'client shared library' in
`/usr/local/lib` . If the `lib` sub-directory does not exist, you can create
it. For example:
2017-11-17 20:06:47 +08:00
2020-06-03 12:14:49 +08:00
```
mkdir /usr/local/lib
ln -s ~/instantclient_19_3/libclntsh.dylib /usr/local/lib
```
2015-02-12 07:14:30 +08:00
2020-06-03 12:14:49 +08:00
Instead of linking, you can also copy all the required OCI libraries, for example:
```
mkdir /usr/local/lib
cp ~/instantclient_19_3/{libclntsh.dylib.19.1,libclntshcore.dylib.19.1,libnnz19.dylib,libociei.dylib} /usr/local/lib/
```
#### 3.3.5 Optionally create the Oracle Client configuration directory
If you use optional Oracle configuration files such as `tnsnames.ora` ,
`sqlnet.ora` or `oraaccess.xml` with Instant Client, then put the files in an
accessible directory, for example in `/Users/your_username/your_config_dir` .
Then use [`oracledb.initOracleClient()`][64] in your application:
```javascript
const oracledb = require('oracledb');
oracledb.initOracleClient({configDir: '/Users/your_username/your_config_dir'});
2017-11-17 20:06:47 +08:00
```
2020-06-03 12:14:49 +08:00
Or you can set the environment variable `TNS_ADMIN` to that directory name.
2017-11-17 20:06:47 +08:00
2020-06-03 12:14:49 +08:00
Another alternative is to put the files in the `network/admin` subdirectory of
Instant Client, for example in
`/Users/your_username/instantclient_19_3/network/admin` . This is the default
Oracle configuration directory for executables linked with this Instant Client.
2017-11-17 20:06:47 +08:00
2020-06-03 12:14:49 +08:00
#### 3.3.6 Run an example program
2017-11-17 20:06:47 +08:00
Download the [example programs][19] from GitHub.
2015-02-12 07:14:30 +08:00
2018-02-06 10:39:51 +08:00
Edit `dbconfig.js` and set the [database credentials][45] to your
2017-06-14 09:49:08 +08:00
environment, for example:
2015-02-12 07:14:30 +08:00
```
module.exports = {
user : "hr",
2019-02-08 09:55:21 +08:00
password : process.env.NODE_ORACLEDB_PASSWORD,
2019-01-11 05:54:53 +08:00
connectString : "localhost/XEPDB1"
2015-02-12 07:14:30 +08:00
};
```
2020-06-03 12:14:49 +08:00
Run one of the examples, such as [`example.js`][63]:
2015-02-12 07:14:30 +08:00
```
2018-09-26 16:02:52 +08:00
node example.js
2015-02-12 07:14:30 +08:00
```
2020-06-03 12:14:49 +08:00
### <a name="windowsinstallation"></a> 3.4 Node-oracledb Installation on Microsoft Windows
There are two ways to install node-oracledb on Linux:
- [Using Instant Client ZIP files ](#instwin )
- [Using a Local Database or Full Client ](#instwinoh )
#### <a name="instwin"></a> 3.4.1 Node-oracledb Installation on Microsoft Windows with Instant Client ZIP files
2017-06-14 09:49:08 +08:00
2019-02-20 05:49:16 +08:00
Follow these steps if your database is on a remote machine, or if you
already have Oracle software installed but you want node-oracledb to
use a different version of the libraries.
2015-02-12 07:14:30 +08:00
2017-11-17 20:06:47 +08:00
Questions and issues can be posted as [GitHub Issues][10].
2015-02-12 07:16:59 +08:00
2020-06-03 12:14:49 +08:00
##### <a name="winprereqs"></a> 3.4.1.1 Install Prerequisites
2015-02-12 07:16:59 +08:00
2017-11-17 20:06:47 +08:00
Review the generic [prerequisites ](#prerequisites ).
2017-06-29 14:35:55 +08:00
2019-07-25 13:00:30 +08:00
The pre-built binaries were built with Visual Studio 2017 and require
2017-12-12 06:56:12 +08:00
the matching [redistributable][27].
2017-11-17 20:06:47 +08:00
You may need Administrator privileges to set environment variables or
install software.
2017-06-14 09:49:08 +08:00
2020-06-03 12:14:49 +08:00
##### 3.4.1.2 Install Node.js
2015-02-12 07:16:59 +08:00
2020-06-03 12:14:49 +08:00
Install the 64-bit Node.js MSI (e.g. node-v12.17.0-x64.msi) from
[nodejs.org][11]. Make sure the option to add the Node and npm directories to
the path is selected.
2015-03-29 07:48:19 +08:00
2020-06-03 12:14:49 +08:00
##### 3.4.1.3 Install node-oracledb
2017-11-17 20:06:47 +08:00
Open a terminal window.
2015-02-12 07:16:59 +08:00
2015-09-25 16:27:16 +08:00
If you are behind a firewall you may need to set your proxy, for
2015-07-20 15:57:32 +08:00
example:
```
2019-08-14 19:48:50 +08:00
npm config set proxy http://myproxy.example.com:80/
2015-07-20 15:57:32 +08:00
```
2018-02-06 10:10:04 +08:00
Install node-oracledb using the `npm` package manager, which is
included in Node.js:
2015-02-12 07:16:59 +08:00
```
2015-03-29 07:48:19 +08:00
npm install oracledb
2015-02-12 07:16:59 +08:00
```
2017-11-17 20:06:47 +08:00
If a pre-built node-oracledb binary is not installable, the binary can
2017-12-12 07:17:52 +08:00
be built from source code, see [Node-oracledb Installation from
Source Code](#github).
2017-11-17 20:06:47 +08:00
2020-06-03 12:14:49 +08:00
##### 3.4.1.4 Install the free Oracle Instant Client ZIP
Download the free 64-bit Instant Client **Basic** ZIP file from [Oracle
Technology Network][25]. If your Node.js architecture is 32-bit, then use the
[32-bit Instant Client][26] instead. Windows 7 users: Note that Oracle 19 is
not supported on Windows 7.
Unzip the ZIP file into a directory that is accessible to your application. For
example unzip ` instantclient-basic-windows.x64-19.6.0.0.0dbru.zip` to
`C:\oracle\instantclient_19_6` .
There are several alternative ways to tell node-oracledb where your Oracle
Client libraries are, see [Initializing Node-oracledb][17]:
2017-11-17 20:06:47 +08:00
2020-06-03 12:14:49 +08:00
- Use [`oracledb.initOracleClient()`][64] in your application:
2019-02-20 05:49:16 +08:00
2020-06-03 12:14:49 +08:00
```javascript
const oracledb = require('oracledb');
try {
2020-06-30 08:41:28 +08:00
oracledb.initOracleClient({libDir: 'C:\\oracle\\instantclient_19_6'});
2020-06-03 12:14:49 +08:00
} catch (err) {
console.error('Whoops!');
console.error(err);
process.exit(1);
}
```
2019-11-19 10:20:43 +08:00
2020-06-30 08:41:28 +08:00
If you use backslashes in the `libDir` string, you will need to double them.
2020-06-03 12:14:49 +08:00
- Alternatively, copy the Oracle Instant Client libraries to the
`node_modules/oracledb/build/Release` directory where the `oracledb*.node`
binary is.
2019-02-20 05:49:16 +08:00
2020-06-03 12:14:49 +08:00
- Alternatively, add the Oracle Instant Client directory to the `PATH`
environment variable. The directory must occur in `PATH` before any other
Oracle directories.
2019-02-20 05:49:16 +08:00
Restart any open command prompt windows.
To avoid interfering with existing tools that require other Oracle
Client versions then, instead of updating the system-wide `PATH`
variable, you may prefer to write a batch file that sets `PATH` , for
example:
2017-06-14 09:49:08 +08:00
2019-02-20 05:49:16 +08:00
```
REM mynode.bat
2020-06-03 12:11:09 +08:00
SET PATH=C:\oracle\instantclient_19_6;%PATH%
2019-02-20 05:49:16 +08:00
node %*
```
2017-06-14 09:49:08 +08:00
2019-07-02 10:46:45 +08:00
Invoke this batch file every time you want to run Node.js.
2017-06-14 09:49:08 +08:00
2019-02-20 05:49:16 +08:00
Alternatively use `SET` to change your `PATH` in each command prompt
window before you run node.
2018-08-22 11:30:06 +08:00
2020-06-03 12:12:53 +08:00
If disk space is important, most users will be able to use the smaller Basic
Light package instead of the Basic package. Review its [globalization
limitations][62]. Disk space can be reduced by removing unnecessary libraries
and files from either the Basic or Basic Light packages. The exact libraries
depend on the Instant Client version. Refer to the Instant Client
documentation.
2020-06-03 12:14:49 +08:00
##### 3.4.1.5 Optionally create the Oracle Client configuration directory
If you use optional Oracle configuration files such as `tnsnames.ora` ,
`sqlnet.ora` or `oraaccess.xml` with Instant Client, then put the files in an
2020-06-30 08:41:28 +08:00
accessible directory. For example if they are in `C:\oracle\your_config_dir`
then use [`oracledb.initOracleClient()`][64] in your application:
2017-11-17 20:06:47 +08:00
2020-06-03 12:14:49 +08:00
```javascript
const oracledb = require('oracledb');
2020-06-30 08:41:28 +08:00
oracledb.initOracleClient({configDir: 'C:\\oracle\\your_config_dir'});
2020-06-03 12:14:49 +08:00
```
2017-11-17 20:06:47 +08:00
2020-06-30 08:41:28 +08:00
If you use backslashes in the `configDir` string, you will need to double them.
2020-06-03 12:14:49 +08:00
Or you can set the environment variable `TNS_ADMIN` to that directory name.
2017-11-17 20:06:47 +08:00
2020-06-30 08:41:28 +08:00
Another alternative is to put the files in the `network\admin` subdirectory of
2020-06-03 12:14:49 +08:00
Instant Client, for example in `C:\oracle\instantclient_19_6\network\admin` .
This is the default Oracle configuration directory for executables linked with
this Instant Client.
2017-11-17 20:06:47 +08:00
2020-06-03 12:14:49 +08:00
##### <a name="winredists"> </a> 3.4.1.6 Install the Visual Studio Redistributables
2017-06-29 14:35:55 +08:00
2017-07-08 10:48:36 +08:00
The `PATH` variable needs to include the appropriate VS Redistributable:
2019-07-02 10:35:56 +08:00
- Oracle client 19 requires the [Visual Studio 2017 Redistributable][27].
2018-08-22 11:12:39 +08:00
- Oracle client 18 and 12.2 require the [Visual Studio 2013 Redistributable][27].
2017-12-12 06:56:12 +08:00
- Oracle client 12.1 requires the [Visual Studio 2010 Redistributable][27].
2017-11-17 20:06:47 +08:00
- Oracle client 11.2 requires the [Visual Studio 2005 Redistributable][29].
2017-06-29 14:35:55 +08:00
You can also find out the version required by locating the library
`OCI.DLL` and running:
```
dumpbin /dependents oci.dll
```
2017-07-08 10:48:36 +08:00
If you see `MSVCR120.dll` then you need the VS 2013 Redistributable.
If you see `MSVCR100.dll` then you need the VS 2010 Redistributable.
If you see `MSVCR80.dll` then you need the VS 2005 Redistributable.
2017-06-29 14:35:55 +08:00
2020-06-03 12:14:49 +08:00
##### 3.4.1.7 Run an example program
2017-11-17 20:06:47 +08:00
Download the [example programs][19] from GitHub.
2018-02-06 10:39:51 +08:00
Edit `dbconfig.js` and set the [database credentials][45] to your
2017-11-17 20:06:47 +08:00
environment, for example:
```
module.exports = {
user : "hr",
2019-02-08 09:55:21 +08:00
password : process.env.NODE_ORACLEDB_PASSWORD,
2019-01-11 05:54:53 +08:00
connectString : "localhost/XEPDB1"
2017-11-17 20:06:47 +08:00
};
```
2020-06-03 12:14:49 +08:00
Run one of the examples, such as [`example.js`][63]:
2017-11-17 20:06:47 +08:00
```
2018-09-26 16:02:52 +08:00
node example.js
2017-11-17 20:06:47 +08:00
```
2020-06-03 12:14:49 +08:00
#### <a name="instwinoh"></a> 3.4.2 Node-oracledb Installation on Microsoft Windows with a Local Database or Full Client
2017-11-17 20:06:47 +08:00
Questions and issues can be posted as [GitHub Issues][10].
2020-06-03 12:14:49 +08:00
##### <a name="winprereqs"></a> 3.4.2.1 Install Prerequisites
2017-11-17 20:06:47 +08:00
Review the generic [prerequisites ](#prerequisites ).
2019-07-25 13:00:30 +08:00
The pre-built binaries were built with Visual Studio 2017 and require
2017-12-12 06:56:12 +08:00
the matching [redistributable][27].
2017-11-17 20:06:47 +08:00
The Oracle software can be either a database home or a full Oracle
client installation. Make sure that `PATH` contains the correct
binary directory, for example `C:\oracle\product\12.2.0\dbhome_1\bin` .
For easy development, the free [Oracle XE][20] version of the database
2019-01-15 05:14:43 +08:00
is available on Windows. Applications developed with XE may be
2017-11-17 20:06:47 +08:00
immediately used with other editions of the Oracle Database.
You may need Administrator privileges to set environment variables or
install software.
2020-06-03 12:14:49 +08:00
##### 3.4.2.2 Install Node.js
2017-11-17 20:06:47 +08:00
2019-07-02 10:35:56 +08:00
Install the 64-bit Node.js MSI (e.g. node-v10.16.0-x64.msi) from
2017-11-17 20:06:47 +08:00
[nodejs.org][11]. Make sure the option to add the Node and npm
directories to the path is selected.
2020-06-03 12:14:49 +08:00
##### 3.4.2.3 Install node-oracledb
2017-11-17 20:06:47 +08:00
Open a terminal window.
If you are behind a firewall you may need to set your proxy, for
example:
```
2019-08-14 19:48:50 +08:00
npm config set proxy http://myproxy.example.com:80/
2017-11-17 20:06:47 +08:00
```
2018-02-06 10:10:04 +08:00
Install node-oracledb using the `npm` package manager, which is
included in Node.js:
2017-11-17 20:06:47 +08:00
```
npm install oracledb
```
If a pre-built node-oracledb binary is not installable, the binary can
2017-12-12 07:17:52 +08:00
be built from source code, see [Node-oracledb Installation from
Source Code](#github).
2017-11-17 20:06:47 +08:00
2020-06-03 12:14:49 +08:00
##### 3.4.2.4 The default Oracle Client configuration directory
2017-11-17 20:06:47 +08:00
Optional Oracle client configuration files such as [`tnsnames.ora`][15],
2020-06-03 12:14:49 +08:00
[`sqlnet.ora`][16], and [`oraaccess.xml`][18] can be placed in
`$ORACLE_HOME\network\admin` .
2017-11-17 20:06:47 +08:00
2020-06-03 12:14:49 +08:00
Alternatively, if you use Oracle client configuration files, they can be put in
2020-06-30 08:41:28 +08:00
another, accessible directory. For example in `C:\oracle\your_config_dir` .
Then use `oracledb.initOracleClient({configDir:
'C:\\oracle\\your_config_dir'});` in your application or set the environment
2017-11-17 20:06:47 +08:00
variable `TNS_ADMIN` to that directory name.
2015-02-12 07:16:59 +08:00
2020-06-03 12:14:49 +08:00
##### 3.4.2.5 Run an example program
2017-11-17 20:06:47 +08:00
Download the [example programs][19] from GitHub.
2015-02-12 07:16:59 +08:00
2018-02-06 10:39:51 +08:00
Edit `dbconfig.js` and set the [database credentials][45] to your
2017-06-14 09:49:08 +08:00
environment, for example:
2015-02-12 07:16:59 +08:00
```
module.exports = {
user : "hr",
2019-02-08 09:55:21 +08:00
password : process.env.NODE_ORACLEDB_PASSWORD,
2019-01-11 05:54:53 +08:00
connectString : "localhost/XEPDB1"
2015-02-12 07:16:59 +08:00
};
```
2020-06-03 12:14:49 +08:00
Run one of the examples, such as [`example.js`][63]:
2016-03-24 14:09:53 +08:00
2015-02-12 07:16:59 +08:00
```
2018-09-26 16:02:52 +08:00
node example.js
2015-02-12 07:16:59 +08:00
```
2020-06-03 12:14:49 +08:00
### <a name="instaix"></a> 3.5 Node-oracledb Installation on AIX on Power Systems with Instant Client ZIP files
2017-11-17 20:06:47 +08:00
Questions and issues can be posted as [GitHub Issues][10].
2015-03-29 07:48:19 +08:00
2020-06-03 12:14:49 +08:00
#### <a name="aixprereqs"></a> 3.5.1 Install Prerequisites
2015-02-12 06:50:35 +08:00
2017-11-17 20:06:47 +08:00
Review the generic [prerequisites ](#prerequisites ).
2015-02-12 06:50:35 +08:00
2019-03-13 14:12:20 +08:00
The GCC compiler is needed.
2015-02-12 06:50:35 +08:00
2017-06-19 07:11:17 +08:00
Use GNU Make 4.1-1 or above.
2015-02-12 06:50:35 +08:00
2017-06-19 07:11:17 +08:00
Python 2.7 is needed by node-gyp.
2015-02-12 06:50:35 +08:00
2020-06-03 12:14:49 +08:00
#### 3.5.2 Install Node.js
2015-02-12 06:50:35 +08:00
2017-11-17 20:06:47 +08:00
Download [Node.js][11] for AIX on Power Systems. For
2019-07-02 10:35:56 +08:00
example, if you downloaded version 10.16.0 you could install Node.js
2017-06-19 07:11:17 +08:00
into `/opt` :
2015-02-12 06:50:35 +08:00
2017-06-19 07:11:17 +08:00
```
cd /opt
2019-07-02 10:35:56 +08:00
gunzip -c node-v10.16.0-aix-ppc64.tar.gz | tar -xvf -
2017-06-19 07:11:17 +08:00
```
Set `PATH` to include Node.js:
2015-02-12 06:50:35 +08:00
```
2019-07-02 10:35:56 +08:00
export PATH=/opt/node-v10.16.0-aix-ppc64/bin:$PATH
2015-02-12 06:50:35 +08:00
```
2016-07-08 14:54:51 +08:00
2020-06-03 12:14:49 +08:00
#### 3.5.3 Install node-oracledb
2016-07-08 14:54:51 +08:00
2017-06-14 09:49:08 +08:00
If you are behind a firewall you may need to set your proxy, for
example:
2016-07-08 14:54:51 +08:00
```
2019-08-14 19:48:50 +08:00
npm config set proxy http://myproxy.example.com:80/
2016-07-08 14:54:51 +08:00
```
2017-06-17 13:49:16 +08:00
Set the compiler to GCC:
```
export CC=gcc
```
2017-11-17 20:06:47 +08:00
Locate the [GitHub tag][40] of the desired node-oracledb version, for
2020-06-30 08:40:57 +08:00
example `v5.1.0` , and use the `npm` package manager (which is
2018-02-06 10:10:04 +08:00
included in Node.js) to install it.
If you have the `git` utility, you can install with:
2016-07-08 14:54:51 +08:00
```
2020-06-30 08:40:57 +08:00
npm install oracle/node-oracledb.git#v5.1.0
2016-07-08 14:54:51 +08:00
```
2017-12-12 07:17:52 +08:00
Otherwise install using:
```
2020-06-30 08:40:57 +08:00
npm install https://github.com/oracle/node-oracledb/releases/download/v5.1.0/oracledb-src-5.1.0.tgz
2017-12-12 07:17:52 +08:00
```
2020-06-03 12:14:49 +08:00
#### 3.5.4 Install the free Oracle Instant Client 'Basic' ZIP file
2016-07-08 14:54:51 +08:00
2017-11-17 20:06:47 +08:00
Download the **Basic** ZIP file from [Oracle Technology Network][30]
and extract it into a directory that is accessible to your
application, for example `/opt/oracle` :
2016-07-08 14:54:51 +08:00
```
2020-06-03 12:11:09 +08:00
unzip instantclient-basic-aix.ppc64-19.6.0.0.0dbru.zip
2017-06-19 07:11:17 +08:00
mkdir -p /opt/oracle
2020-06-03 12:11:09 +08:00
mv instantclient_19_6 /opt/oracle
2016-07-08 14:54:51 +08:00
```
To run applications, you will need to set the link path:
```
2020-06-03 12:11:09 +08:00
export LIBPATH=/opt/oracle/instantclient_19_6:$LIBPATH
2016-07-08 14:54:51 +08:00
```
2020-06-03 12:14:49 +08:00
#### 3.5.5 Optionally create the Oracle Client configuration directory
2017-11-17 20:06:47 +08:00
2020-06-03 12:14:49 +08:00
If you use optional Oracle configuration files such as `tnsnames.ora` ,
`sqlnet.ora` or `oraaccess.xml` with Instant Client, then put the files in an
accessible directory, for example in `/opt/oracle/your_config_dir` . Then use the
following in your application:
2017-11-17 20:06:47 +08:00
2020-06-03 12:14:49 +08:00
```javascript
const oracledb = require('oracledb');
oracledb.initOracleClient({configDir: '/opt/oracle/your_config_dir'});
2017-11-17 20:06:47 +08:00
```
2020-06-03 12:14:49 +08:00
Or you can set the environment variable `TNS_ADMIN` to that directory name.
2017-11-17 20:06:47 +08:00
2020-06-03 12:14:49 +08:00
Another alternative is to put the files in the `network/admin` subdirectory of
Instant Client, for example in `/opt/oracle/instantclient_19_6/network/admin` .
This is the default Oracle configuration directory for executables linked with
this Instant Client.
2017-11-17 20:06:47 +08:00
2020-06-03 12:14:49 +08:00
#### 3.5.6 Run an example program
2016-07-08 14:54:51 +08:00
2017-11-17 20:06:47 +08:00
Download the [example programs][19] from GitHub.
2016-07-08 14:54:51 +08:00
2018-02-06 10:39:51 +08:00
Edit `dbconfig.js` and set the [database credentials][45] to your
2017-06-14 09:49:08 +08:00
environment, for example:
2016-07-08 14:54:51 +08:00
```
module.exports = {
user : "hr",
2019-02-08 09:55:21 +08:00
password : process.env.NODE_ORACLEDB_PASSWORD,
2019-01-11 05:54:53 +08:00
connectString : "localhost/XEPDB1"
2016-07-08 14:54:51 +08:00
};
```
2020-06-03 12:14:49 +08:00
Run one of the examples, such as [`example.js`][63]:
2016-07-08 14:54:51 +08:00
```
2018-09-26 16:02:52 +08:00
node example.js
2016-07-08 14:54:51 +08:00
```
2020-06-03 12:14:49 +08:00
### <a name="instsolarisx8664"></a> 3.6 Node-oracledb Installation on Oracle Solaris x86-64 (64-Bit) with Instant Client ZIP files
2016-07-08 14:54:51 +08:00
2017-11-17 20:06:47 +08:00
Questions and issues can be posted as [GitHub Issues][10].
2016-07-08 14:54:51 +08:00
2020-06-03 12:14:49 +08:00
#### 3.6.1 Install Prerequisites
2016-07-08 14:54:51 +08:00
2017-11-17 20:06:47 +08:00
Review the generic [prerequisites ](#prerequisites ).
2020-06-03 12:14:49 +08:00
#### 3.6.2 Install Node.js
2017-11-17 20:06:47 +08:00
Download the [Node.js source code][11].
2017-06-14 09:49:08 +08:00
Compile and build the Node.js engine into a directory of your choice,
such as `/opt/node` :
2016-07-08 14:54:51 +08:00
```
2017-06-14 09:49:08 +08:00
./configure --dest-cpu=x64 --dest-os=solaris --prefix=/opt/node
make
make install
2016-07-08 14:54:51 +08:00
```
2017-07-08 10:48:36 +08:00
*Note:* if warnings are shown for `objdump` and `dtrace` , then set
2017-06-14 09:49:08 +08:00
`PATH` to include these binaries. This is most likely `/usr/gnu/bin`
and `/usr/bin` , respectively.
2016-07-08 14:54:51 +08:00
2017-06-14 09:49:08 +08:00
Set `PATH` to include the Node.js and Node-gyp binaries
2016-07-08 14:54:51 +08:00
```
2017-06-14 09:49:08 +08:00
export PATH=/opt/node/bin:/opt/node/lib/node_modules/npm/bin/node-gyp-bin:$PATH
2016-07-08 14:54:51 +08:00
```
2020-06-03 12:14:49 +08:00
#### 3.6.3 Install node-oracledb
2016-07-08 14:54:51 +08:00
2017-06-14 09:49:08 +08:00
If you are behind a firewall you may need to set your proxy, for
example:
2016-07-08 14:54:51 +08:00
```
2019-08-14 19:48:50 +08:00
npm config set proxy http://myproxy.example.com:80/
2016-07-08 14:54:51 +08:00
```
2017-11-17 20:06:47 +08:00
Use the GNU `gmake` utility:
2016-07-08 14:54:51 +08:00
```
2017-08-01 12:01:01 +08:00
export MAKE=gmake
2016-07-08 14:54:51 +08:00
```
2017-11-17 20:06:47 +08:00
Locate the [GitHub tag][40] of the desired node-oracledb version, for
2020-06-30 08:40:57 +08:00
example `v5.1.0` , and use the `npm` package manager (which is
2018-02-06 10:10:04 +08:00
included in Node.js) to install it.
If you have the `git` utility, you can install with:
2016-07-08 14:54:51 +08:00
2017-11-17 20:06:47 +08:00
```
2020-06-30 08:40:57 +08:00
npm install oracle/node-oracledb.git#v5.1.0
2017-11-17 20:06:47 +08:00
```
2017-12-12 07:17:52 +08:00
Otherwise install using:
```
2020-06-30 08:40:57 +08:00
npm install https://github.com/oracle/node-oracledb/releases/download/v5.1.0/oracledb-src-5.1.0.tgz
2017-12-12 07:17:52 +08:00
```
2020-06-26 14:51:26 +08:00
If this fails due to an invalid `cp -a` option, you can download the
node-oracledb source from GitHub. Then use `node-gyp configure` . Edit
`build/Makefile` and change the `cmd_copy` definition `cp` options from `cp -af`
to `cp -pPR` . Finally, run `node-gyp build` .
2020-06-03 12:14:49 +08:00
#### 3.6.4 Install the free Oracle Instant Client 'Basic' ZIP file
2017-11-17 20:06:47 +08:00
Download the **Basic** ZIP file from [Oracle Technology Network][31]
and extract it into a directory that is accessible to your
application, for example `/opt/oracle` :
2016-07-08 14:54:51 +08:00
```
cd /opt/oracle
2020-06-03 12:11:09 +08:00
unzip instantclient-basic-solaris.x64-19.6.0.0.0dbru.zip
2016-07-08 14:54:51 +08:00
```
To run applications, you will need to set the link path:
```
2020-06-03 12:11:09 +08:00
export LD_LIBRARY_PATH_64=/opt/oracle/instantclient_19_6:$LD_LIBRARY_PATH_64
2016-07-08 14:54:51 +08:00
```
2020-06-03 12:14:49 +08:00
#### 3.6.5 Optionally create the Oracle Client configuration directory
2017-11-17 20:06:47 +08:00
2020-06-03 12:14:49 +08:00
If you use optional Oracle configuration files such as `tnsnames.ora` ,
`sqlnet.ora` or `oraaccess.xml` with Instant Client, then put the files in an
accessible directory, for example in `/opt/oracle/your_config_dir` . Then use the
following in your application:
2017-11-17 20:06:47 +08:00
2020-06-03 12:14:49 +08:00
```javascript
const oracledb = require('oracledb');
oracledb.initOracleClient({configDir: '/opt/oracle/your_config_dir'});
2017-11-17 20:06:47 +08:00
```
2020-06-03 12:14:49 +08:00
Or you can set the environment variable `TNS_ADMIN` to that directory name.
2017-11-17 20:06:47 +08:00
2020-06-03 12:14:49 +08:00
Another alternative is to put the files in the `network/admin` subdirectory of
Instant Client, for example in `/opt/oracle/instantclient_19_6/network/admin` .
This is the default Oracle configuration directory for executables linked with
this Instant Client.
2017-11-17 20:06:47 +08:00
2020-06-03 12:14:49 +08:00
#### 3.6.6 Run an example program
2016-07-08 14:54:51 +08:00
2017-11-17 20:06:47 +08:00
Download the [example programs][19] from GitHub.
2016-07-08 14:54:51 +08:00
2018-02-06 10:39:51 +08:00
Edit `dbconfig.js` and set the [database credentials][45] to your
2017-06-14 09:49:08 +08:00
environment, for example:
2016-07-08 14:54:51 +08:00
```
module.exports = {
user : "hr",
2019-02-08 09:55:21 +08:00
password : process.env.NODE_ORACLEDB_PASSWORD,
2019-01-11 05:54:53 +08:00
connectString : "localhost/XEPDB1"
2016-07-08 14:54:51 +08:00
};
```
2020-06-03 12:14:49 +08:00
Run one of the examples, such as [`example.js`][63]:
2016-07-08 14:54:51 +08:00
```
2018-09-26 16:02:52 +08:00
node example.js
2016-07-08 14:54:51 +08:00
```
2017-06-29 14:35:55 +08:00
2020-06-03 12:14:49 +08:00
### <a name="github"></a> 3.7 Node-oracledb Installation from Source Code
2017-12-12 07:17:52 +08:00
2020-02-16 08:16:59 +08:00
Node-oracledb can be compiled from the source code.
2017-12-12 07:17:52 +08:00
2020-06-03 12:14:49 +08:00
#### <a name="compileenv"></a> 3.7.1 Environment for compiling from source code
2020-02-16 08:16:59 +08:00
Some build tools are required to compile node-oracledb.
Install [Python 2.7][2], which is required for the node-gyp utility. (Note:
recent Node.js tools should work with Python 3).
2017-12-12 07:17:52 +08:00
- If another version of Python occurs first in your binary path then
run `npm config set python /wherever/python-2.7/bin/python` or use
the `--python` option to indicate the correct version. For example:
`npm install --python=/whereever/python-2.7/bin/python oracledb` .
- On Windows, install the Python 2.7 MSI and select the customization
option to "Add python.exe to Path".
2019-03-13 14:12:20 +08:00
Install a C compiler:
2017-12-12 07:17:52 +08:00
2019-03-13 14:12:20 +08:00
- On Linux, GCC 4.4.7 (the default on Oracle Linux 6) is known to work.
2017-12-12 07:17:52 +08:00
- On macOS install Xcode from the Mac App store.
2019-03-13 14:12:20 +08:00
- On Windows, install a C build environment such as Microsoft
2019-07-25 13:00:30 +08:00
Visual Studio 2017. Compilers supported by Oracle libraries are
2017-12-12 07:17:52 +08:00
found in [Oracle documentation][23] for each version, for example
2018-08-22 11:12:39 +08:00
[Oracle Database Client Installation Guide for
2017-12-12 07:17:52 +08:00
Microsoft Windows][24]. Some users report that the npm
`windows-build-tools` package has the necessary tools to build
node-oracledb from source code.
The directories with the `python` and `npm` executables should be in your
PATH environment variable. On Windows you can use vcvars64.bat (or
vcvars.bat if you building with 32-bit binaries) to set the
environment. Alternatively you can open the 'Developer Command Prompt
for Visual Studio' which has environment variables already configured.
2017-11-17 20:06:47 +08:00
2020-06-03 12:14:49 +08:00
#### <a name="githubclone"></a> 3.7.2 Installing GitHub clones and ZIP files
2020-02-16 08:16:59 +08:00
If you clone the node-oracledb repository, or download a zip from [GitHub][1] to
build node-oracledb from source code, then you need to make sure the [ODPI-C
submodule][9] is also included. Otherwise the build will fail with an error
like ** 'dpi.h' file not found**.
- If you download a node-oracledb ZIP file from GitHub, you must separately
download the ODPI-C submodule code and extract it into a `odpi` subdirectory.
- When cloning the node-oracledb repository, include ODPI-C by doing:
```
git clone https://github.com/oracle/node-oracledb.git
cd node-oracledb
git submodule init
git submodule update
```
2020-06-03 12:14:49 +08:00
To install, change to your application directory, and then run `npm install
your_dir_path/node-oracledb`. Or add `file:/your_dir_path/node-oracledb` to
your `package.json` dependencies.
2017-11-17 20:06:47 +08:00
2020-06-03 12:14:49 +08:00
#### <a name="githubtags"></a> 3.7.3 Installing using GitHub branches and tags
2017-12-12 07:17:52 +08:00
2020-02-16 08:16:59 +08:00
Node-oracledb can be installed from GitHub tags and branches. The `git` source
code utility is required for this method.
2017-11-17 20:06:47 +08:00
2020-06-03 12:14:49 +08:00
Build node-oracledb from source code by changing the package specifier so that
`npm` downloads from GitHub. For example, to install the code from the GitHub
2020-06-30 08:40:57 +08:00
tag `v5.1.0` , use a `package.json` dependency like:
2017-11-17 20:06:47 +08:00
```
2020-06-03 12:14:49 +08:00
"dependencies": {
2020-06-30 08:40:57 +08:00
"oracledb": "oracle/node-oracledb#v5.1.0"
2020-06-03 12:14:49 +08:00
},
2017-11-17 20:06:47 +08:00
```
2020-06-03 12:14:49 +08:00
Alternatively, use the command:
2017-12-12 07:17:52 +08:00
```
2020-06-30 08:40:57 +08:00
npm install oracle/node-oracledb#v5.1.0
2017-12-12 07:17:52 +08:00
```
2020-06-03 12:14:49 +08:00
To install the current code on the master branch, use
`oracle/node-oracledb#master` .
2020-02-16 08:16:59 +08:00
These commands will download, compile and install node-oracledb. Due to the
slow download of source code from GitHub, it may take some time before
compilation begins.
2017-11-17 20:06:47 +08:00
2020-06-03 12:14:49 +08:00
#### <a name="sourcepackage"></a> 3.7.4 Installing from a source package
2017-11-17 20:06:47 +08:00
2020-02-16 08:16:59 +08:00
Users without the `git` utility can compile pre-bundled source code:
2017-11-17 20:06:47 +08:00
2020-02-16 08:16:59 +08:00
```
2020-06-30 08:40:57 +08:00
npm install https://github.com/oracle/node-oracledb/releases/download/v5.1.0/oracledb-src-5.1.0.tgz
2020-02-16 08:16:59 +08:00
```
2017-11-17 20:06:47 +08:00
2020-02-16 08:16:59 +08:00
Due to the slow download of source code from GitHub, it may take some time
before compilation begins. You may prefer to download
2020-06-30 08:40:57 +08:00
`oracledb-src-5.1.0.tgz` and install with:
2017-11-17 20:06:47 +08:00
2020-02-16 08:16:59 +08:00
```
2020-06-30 08:40:57 +08:00
npm install your_dir_path/oracledb-src-5.1.0.tgz
2020-02-16 08:16:59 +08:00
```
2018-02-09 16:55:52 +08:00
2020-06-03 12:14:49 +08:00
#### <a name="nogithubaccess"></a> 3.7.5 Installing from Oracle's repository
2018-02-09 16:55:52 +08:00
2020-02-16 08:16:59 +08:00
Oracle has a mirror of the GitHub repository source code that can be cloned
with:
2018-02-09 16:55:52 +08:00
```
git clone git://oss.oracle.com/git/oracle/node-oracledb.git/
2019-02-11 07:09:08 +08:00
cd node-oracledb
git submodule init
git submodule update
2018-02-09 16:55:52 +08:00
```
2020-02-16 08:16:59 +08:00
To install, first change to a directory outside the clone directory, and then
2020-06-03 12:14:49 +08:00
run `npm install your_dir_path/your-clone-directory` .
2020-02-16 08:16:59 +08:00
2020-06-03 12:14:49 +08:00
#### <a name="compilepackage"></a> 3.7.6 Creating a node-oracledb package from source code
2020-02-16 08:16:59 +08:00
You can create a package containing the binary module and required JavaScript
files. This is equivalent to the package that is normally installed from the
2020-06-03 12:14:49 +08:00
[npm registry][4]. Your new package can be [self-hosted ](#selfhost ) for use
within your company, or it can be used directly from the file system to install
2020-02-16 08:16:59 +08:00
node-oracledb.
- Download
2020-06-30 08:40:57 +08:00
[`oracledb-src-5.1.0.tgz` ](https://github.com/oracle/node-oracledb/releases/download/v5.1.0/oracledb-src-5.1.0.tgz )
2020-02-16 08:16:59 +08:00
from GitHub.
2020-06-30 08:40:57 +08:00
- Extract the file: `tar -xzf oracledb-src-5.1.0.tgz`
2020-02-16 08:16:59 +08:00
- Change directory: `cd package`
- Run: `npm run buildbinary`
Ignore errors about `git` , which is used to record some basic metadata when
this command is run in git clone.
- Optionally run the above commands on other architectures and copy the
resulting `package/Staging/*` files to your local `package/Staging` directory.
This will allow the final node-oracledb package to be installed on multiple
architectures.
- Run: `npm run buildpackage`
2020-06-30 08:40:57 +08:00
The package `oracledb-5.1.0.tgz` is created.
2020-02-16 08:16:59 +08:00
This package can be shared or self-hosted, see [Hosting your own node-oracledb
Packages](#selfhost).
2020-06-03 12:14:49 +08:00
### <a name="offline"></a> <a name="intermediateinstall"></a> 3.8 Node-oracledb Installation Without Internet Access
2018-02-09 16:55:52 +08:00
2020-02-16 08:16:59 +08:00
On a machine with access, download the node-oracledb package from [npm][4], for
example from
2020-06-30 08:40:57 +08:00
[`https://registry.npmjs.com/oracledb/-/oracledb-5.1.0.tgz` ](https://registry.npmjs.com/oracledb/-/oracledb-5.1.0.tgz )
2020-02-16 08:16:59 +08:00
This can be transferred to the desired machine and installed, for example with:
2017-12-12 06:39:15 +08:00
2020-02-16 08:16:59 +08:00
```
2020-06-30 08:40:57 +08:00
npm install your_dir_path/oracledb-5.1.0.tgz
2020-02-16 08:16:59 +08:00
```
If you are using an architecture that does not have pre-supplied binaries then
you can build your own package, see [Creating a node-oracledb package from
source code](#compilepackage).
Consider self-hosting the node-oracledb package inside your network, see
[Hosting your own node-oracledb Packages ](#selfhost ).
Alternatively, on an identical machine that has access to the internet, install
node-oracle following the [Node-oracledb Installation
Instructions](#instructions) for that operating system. Then copy
`node_modules/oracledb` and Oracle Client libraries to the offline computer.
Windows users should see the next section and make sure the correct Visual
Studio Redistributable is also installed.
2017-12-12 06:39:15 +08:00
2020-06-03 12:14:49 +08:00
#### <a name="winbins"></a> 3.8.1 Copying node-oracledb Binaries on Windows
2017-12-12 06:39:15 +08:00
2018-12-07 13:31:23 +08:00
Node-oracledb binaries can be copied between compatible Windows systems.
2017-12-12 06:39:15 +08:00
2018-12-07 13:31:23 +08:00
After node-oracledb has been built or installed on the source
computer, copy the `node_modules\oracledb` directory to the
destination computer's `node_module` directory.
2017-12-12 06:39:15 +08:00
2018-12-07 13:31:23 +08:00
Both computers must have the same version and architecture (32-bit or
64-bit) of Node.js.
2017-12-12 06:39:15 +08:00
2018-12-07 13:31:23 +08:00
Oracle client libraries of the same architecture as Node.js should be
in the destination computer's `PATH` . They may alternatively be in
the directory `node_modules\oracledb\build\Release` where the
`oracledb.node` binary is located. Note the Oracle client library
versions do not have to be the same on different computers, but
node-oracledb behavior and features may then differ.
2017-12-12 06:39:15 +08:00
2018-12-07 13:31:23 +08:00
The destination computer's `PATH` needs to include Visual Studio
2019-07-02 10:35:56 +08:00
Redistributables. If you have Oracle client 19 install the Visual
Studio 2017 Redistributable. If you have Oracle client 18 or 12.2,
install the Visual Studio 2013 Redistributable. For Oracle client
12.1 install the Visual Studio 2010 Redistributable. For Oracle
client 11.2 install the Visual Studio 2005 Redistributable.
2017-11-17 20:06:47 +08:00
2018-12-07 13:31:23 +08:00
You can also find out the Redistributable required by locating the
library `OCI.DLL` on the source computer and running:
2018-03-27 13:44:52 +08:00
2018-12-07 13:31:23 +08:00
```
dumpbin /dependents oci.dll
```
2018-03-27 13:44:52 +08:00
2018-12-07 13:31:23 +08:00
If you see `MSVCR120.dll` then you need the VS 2013 Redistributable.
If you see `MSVCR100.dll` then you need the VS 2010 Redistributable.
If you see `MSVCR80.dll` then you need the VS 2005 Redistributable.
2018-03-27 13:44:52 +08:00
2020-06-03 12:14:49 +08:00
### <a name="selfhost"></a> 3.9 Hosting your own node-oracledb Packages
2020-02-16 08:16:59 +08:00
You can host node-oracledb packages locally.
Download the node-oracledb package from npm, for example from
2020-06-30 08:40:57 +08:00
[`https://registry.npmjs.com/oracledb/-/oracledb-5.1.0.tgz` ](https://registry.npmjs.com/oracledb/-/oracledb-5.1.0.tgz )
2020-02-16 08:16:59 +08:00
Alternatively, if you want to build your own binaries and node-oracledb package,
see [Creating a node-oracledb package from source code ](#compilepackage ).
If you make the package accessible on your local web server, for
2020-06-30 08:40:57 +08:00
example at www.example.com/oracledb-5.1.0.tgz, then your
2020-02-16 08:16:59 +08:00
install command would be:
```
2020-06-30 08:40:57 +08:00
npm install https://www.example.com/oracledb-5.1.0.tgz
2020-02-16 08:16:59 +08:00
```
or your `package.json` would contain:
```
. . .
"dependencies": {
2020-06-30 08:40:57 +08:00
"oracledb": "https://www.example.com/oracledb-5.1.0.tgz"
2020-02-16 08:16:59 +08:00
},
. . .
```
2020-06-03 12:14:49 +08:00
### <a name="docker"></a> 3.10 Using node-oracledb in Docker
2019-11-25 10:14:39 +08:00
[Docker][59] allows applications to be containerized. Each application will
have a `Dockerfile` with steps to create a Docker image. Once created, the
image can be shared and run.
2020-06-25 07:38:09 +08:00
Sample Dockerfiles for Oracle Linux are available on [GitHub][65].
2019-11-25 10:14:39 +08:00
#### Installing Node.js in Docker
If your `Dockerfile` uses Oracle Linux:
```
FROM oraclelinux:7-slim
```
Then you can install Node.js from [yum.oracle.com][46] using:
```
2020-06-25 07:38:09 +08:00
RUN yum -y install oracle-nodejs-release-el7 & & \
2019-11-25 10:14:39 +08:00
yum -y install nodejs & & \
rm -rf /var/cache/yum
```
2020-06-25 07:38:09 +08:00
One alternative to Oracle Linux is to use a [Node.js image from Docker Hub][56],
for example using:
2019-11-25 10:14:39 +08:00
```
FROM node:12-buster-slim
```
2020-05-20 20:50:15 +08:00
Note: you should review Oracle's supported distributions before choosing an
operating system.
2019-11-25 10:14:39 +08:00
#### Installing Instant Client in Docker
Review the [Oracle Technology Network][12] or the [Oracle Linux 7][51] channel
2020-02-16 07:51:13 +08:00
for the latest Instant Client package available. There are various ways to
install Instant Client. Three methods are shown below.
2019-11-25 10:14:39 +08:00
1. Using Oracle Linux Instant Client RPMs
If you have an Oracle Linux image:
```
FROM oraclelinux:7-slim
```
Then you can install Instant Client RPMs:
```
RUN yum -y install oracle-release-el7 & & \
2020-06-03 12:11:09 +08:00
yum -y install oracle-instantclient19.6-basiclite & & \
2019-11-25 10:14:39 +08:00
rm -rf /var/cache/yum
```
2020-06-03 12:09:34 +08:00
On recent Linux versions, such as Oracle Linux 8, you may also need to
manually install the `libnsl` package.
2020-02-16 08:16:59 +08:00
2. Automatically downloading an Instant Client ZIP file
2019-11-25 10:14:39 +08:00
2020-02-16 08:16:59 +08:00
You can automatically download an Instant Client ZIP file during image
2020-05-20 20:50:15 +08:00
creation. This is most useful on Debian-based operating systems. (Note: you
should review Oracle's supported distributions before choosing an operating
system).
2019-11-25 10:14:39 +08:00
2020-02-16 07:51:13 +08:00
The `libaio` (or `libaio1` ), `wget` and `unzip` packages will need to be
added manually.
2019-11-25 10:14:39 +08:00
2020-02-16 07:51:13 +08:00
On Oracle Linux:
2019-11-25 10:14:39 +08:00
2020-02-16 07:51:13 +08:00
```
RUN yum install -y libaio wget unzip
```
2019-11-25 10:14:39 +08:00
2020-02-16 07:51:13 +08:00
On a Debian-based Linux:
```
RUN apt-get update & & apt-get install -y libaio1 wget unzip
```
2019-11-25 10:14:39 +08:00
2020-02-16 07:51:13 +08:00
Then, to use the latest available Instant Client:
2019-11-25 10:14:39 +08:00
2020-02-16 07:51:13 +08:00
```
RUN wget https://download.oracle.com/otn_software/linux/instantclient/instantclient-basiclite-linuxx64.zip & & \
unzip instantclient-basiclite-linuxx64.zip & & rm -f instantclient-basiclite-linuxx64.zip & & \
2020-06-03 12:11:34 +08:00
cd /opt/oracle/instantclient* && rm -f *jdbc* *occi* *mysql* *mql1* *ipc1* *jar uidrvci genezi adrci && \
2020-02-16 07:51:13 +08:00
echo /opt/oracle/instantclient* > /etc/ld.so.conf.d/oracle-instantclient.conf & & ldconfig
```
2019-11-25 10:14:39 +08:00
2020-06-03 12:09:34 +08:00
On recent Linux versions, such as Oracle Linux 8, you may also need to
install the `libnsl` package.
2019-11-25 10:14:39 +08:00
3. Copying Instant Client zip files from the host
2020-02-16 07:51:13 +08:00
To avoid the cost of repeated network traffic, you may prefer to download the
Instant Client Basic Light zip file to your Docker host, extract it, and
remove unnecessary files. The resulting directory can be added during
subsequent image creation. For example, with Instant Client Basic Light
2020-06-03 12:11:09 +08:00
19.6, the host computer (where you run Docker) could have a directory
`instantclient_19_6` with these files:
2019-11-25 10:14:39 +08:00
2020-02-16 07:51:13 +08:00
```
libclntshcore.so.19.1
libclntsh.so.19.1
libnnz19.so
libociicus.so
```
2019-11-25 10:14:39 +08:00
2020-02-16 07:51:13 +08:00
With this, your Dockerfile could contain:
2019-11-25 10:14:39 +08:00
2020-02-16 07:51:13 +08:00
```
2020-06-03 12:11:09 +08:00
ADD instantclient_19_6/* /opt/oracle/instantclient_19_6
RUN echo /opt/oracle/instantclient_19_6 > /etc/ld.so.conf.d/oracle-instantclient.conf & & \
2020-02-16 07:51:13 +08:00
ldconfig
```
The `libaio` or `libaio1` package will be needed.
On Oracle Linux:
```
RUN yum install -y libaio
```
2019-11-25 10:14:39 +08:00
2020-02-16 07:51:13 +08:00
On a Debian-based Linux:
```
RUN apt-get update & & apt-get install -y libaio1
```
2019-11-25 10:14:39 +08:00
2020-06-03 12:09:34 +08:00
On recent Linux versions, such as Oracle Linux 8, you may also need to
install the `libnsl` package.
2019-11-25 10:14:39 +08:00
#### Installing node-oracledb and your application
Include node-oracledb as a normal dependency in your application `package.json` file:
```
. . .
"scripts": {
"start": "node server.js"
},
"dependencies": {
"oracledb" : "^4"
},
. . .
```
The `packge.json` and application file can be added to the image, and
dependencies installed when the image is built:
```
WORKDIR /myapp
2020-02-16 07:51:13 +08:00
ADD package.json server.js /myapp/
2019-11-25 10:14:39 +08:00
RUN npm install
CMD exec node server.js
```
#### Using Oracle Net configuration files and Oracle Wallets
[Optional Oracle Net Configuration][58] files (like `tnsnames.ora` and
`sqlnet.net` ) and files that need to be secured such as [Oracle wallets][57] can
be mounted at runtime using a Docker volume. Map the volume to the
`network/admin` subdirectory of Instant Client so the `TNS_ADMIN` environment
variable does not need to be set. For example, when the Wallet or configuration
files are in `/OracleCloud/wallet/` on the host computer, and the image uses
2020-06-03 12:11:09 +08:00
Instant Client 19.6 RPMs, then you can mount the files using:
2019-11-25 10:14:39 +08:00
```
2020-06-03 12:11:09 +08:00
docker run -v /OracleCloud/wallet:/usr/lib/oracle/19.6/client64/lib/network/admin:Z,ro . . .
2019-11-25 10:14:39 +08:00
```
The `Z` option is needed when SELinux is enabled.
#### <a name="dockerexample"></a> Example Application in Docker
This example consists of a `Dockerfile` , a `package.json` file with the
application dependencies, a `server.js` file that is the application, and an
2020-02-16 07:51:13 +08:00
`envfile.list` containing the database credentials as environment variables.
2019-11-25 10:14:39 +08:00
2020-02-16 07:51:13 +08:00
If you use Oracle Linux, your `Dockerfile` will be like:
2019-11-25 10:14:39 +08:00
```
FROM oraclelinux:7-slim
RUN yum -y install oracle-release-el7 oracle-nodejs-release-el7 & & \
2020-06-03 12:11:09 +08:00
yum -y install nodejs oracle-instantclient19.6-basiclite & & \
2019-11-25 10:14:39 +08:00
rm -rf /var/cache/yum
WORKDIR /myapp
2020-02-16 07:51:13 +08:00
ADD package.json server.js /myapp/
RUN npm install
CMD exec node server.js
```
An equivalent Dockerfile that uses a Node.js image is:
```
FROM node:12-buster-slim
RUN apt-get update & & apt-get install -y libaio1 wget unzip
WORKDIR /opt/oracle
RUN wget https://download.oracle.com/otn_software/linux/instantclient/instantclient-basiclite-linuxx64.zip & & \
unzip instantclient-basiclite-linuxx64.zip & & rm -f instantclient-basiclite-linuxx64.zip & & \
2020-06-03 12:11:34 +08:00
cd /opt/oracle/instantclient* && rm -f *jdbc* *occi* *mysql* *mql1* *ipc1* *jar uidrvci genezi adrci && \
2020-02-16 07:51:13 +08:00
echo /opt/oracle/instantclient* > /etc/ld.so.conf.d/oracle-instantclient.conf & & ldconfig
WORKDIR /myapp
ADD package.json server.js /myapp/
2019-11-25 10:14:39 +08:00
RUN npm install
CMD exec node server.js
```
2020-02-16 07:51:13 +08:00
For either Dockerfile, the `package.json` is:
2019-11-25 10:14:39 +08:00
```
{
"name": "test",
"version": "1.0.0",
"private": true,
"description": "Docker Node.js application",
"scripts": {
"start": "node server.js"
},
"keywords": [
"myapp"
],
"dependencies": {
2020-06-25 07:38:09 +08:00
"oracledb" : "^5"
2019-11-25 10:14:39 +08:00
},
"author": "Me",
"license": "UPL"
}
```
2020-02-16 07:51:13 +08:00
The application `server.js` contains code like:
2019-11-25 10:14:39 +08:00
```javascript
. . .
connection = await oracledb.getConnection({
user: process.env.NODE_ORACLEDB_USER,
password: process.env.NODE_ORACLEDB_PASSWORD,
connectString: process.env.NODE_ORACLEDB_CONNECTIONSTRING
});
const result = await connection.execute(
`SELECT TO_CHAR(CURRENT_DATE, 'DD-Mon-YYYY HH24:MI') AS D FROM DUAL` ,
[],
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
console.log(result);
. . .
```
The environment variables in `envfile.list` are used at runtime. The file
contains:
```
NODE_ORACLEDB_USER=hr
NODE_ORACLEDB_PASSWORD=< hr password >
NODE_ORACLEDB_CONNECTIONSTRING=server.example.com/orclpdb1
```
The image can be built:
```
docker build -t nodedoc .
```
Alternatively, if you are behind a firewall, you can pass proxies when building:
```
docker build --build-arg https_proxy=http://myproxy.example.com:80 --build-arg http_proxy=http://www-myproxy.example.com:80 -t nodedoc .
```
Finaly, a container can be run from the image:
```
docker run -ti --name nodedoc --env-file envfile.list nodedoc
```
The output is like:
```
{ metaData: [ { name: 'D' } ],
rows: [ { D: '24-Nov-2019 23:39' } ] }
```
2018-12-07 13:31:23 +08:00
2020-06-25 07:38:09 +08:00
## <a name="installingoldvers"></a> <a name="installingv2"></a> <a name="installingv1"></a> 4. Installing Older Versions of Node-oracledb
2017-06-29 14:35:55 +08:00
2020-06-25 07:38:09 +08:00
Pre-built node-oracledb 3 and 4 binaries are available for some platforms and
2019-08-14 19:48:50 +08:00
Node.js versions. Review the [release tags][41] for availability. You can
2020-06-25 07:38:09 +08:00
compile the add-on for other platforms or versions.
The node-oracledb 4.2 installation steps are in the [version 4.2 INSTALL
guide][66].
2019-08-14 19:48:50 +08:00
The node-oracledb 3.1 installation steps are in the [version 3.1 INSTALL
guide][55].
2020-06-25 07:38:09 +08:00
To get an old add-on you must explicitly use its version when installing, for
example:
2018-12-23 06:53:34 +08:00
```
2020-06-25 07:38:09 +08:00
npm install oracledb@4.2.0
2018-12-23 06:53:34 +08:00
```
or your `package.json` could contain:
```
. . .
"dependencies": {
2020-06-25 07:38:09 +08:00
"oracledb": "4.2.0"
2018-12-23 06:53:34 +08:00
},
. . .
```
2017-12-12 06:39:15 +08:00
2019-08-14 19:48:50 +08:00
## <a name="troubleshooting"></a> 5. Troubleshooting Node-oracledb Installation Problems
2017-06-29 14:35:55 +08:00
2017-12-12 07:17:52 +08:00
*Read the [Node-oracledb Installation Instructions ](#instructions )*.
**Google anything that looks like an error.**
2017-07-11 10:41:54 +08:00
If `npm install oracledb` fails:
2017-06-29 14:35:55 +08:00
2018-12-07 13:31:23 +08:00
- Review the error messages closely. If a pre-built node-oracledb
binary package is not available for your Node.js version or
operating system, then change your Node.js version or compile
node-oracledb from source code.
2018-02-21 07:53:15 +08:00
2019-08-14 19:48:50 +08:00
- Was there a network connection error? Do you need to use `npm config set
proxy`, or set `http_proxy` and/or `https_proxy` ?
2018-02-21 07:53:15 +08:00
2017-07-08 10:48:36 +08:00
- Use `npm install --verbose oracledb` . Review your output and logs.
2017-12-12 07:17:52 +08:00
Try to install in a different way. Try some potential solutions.
2017-07-08 10:48:36 +08:00
2018-02-21 07:53:15 +08:00
- When compiling node-oracledb from source, do you have Python 2.7?
Run `python --version` .
2017-07-11 10:41:54 +08:00
2018-12-07 13:31:23 +08:00
- When compiling node-oracledb from source, do you have an old version
of `node-gyp` installed? Try updating it. Also try deleting
`$HOME/.node-gyp` or equivalent.
2017-07-11 10:41:54 +08:00
- Try running `npm cache clean -f` and deleting the
`node_modules/oracledb` directory.
2018-11-27 10:51:39 +08:00
If creating a connection fails:
2020-06-25 07:38:09 +08:00
- If you got *DPI-1047: Cannot locate an Oracle Client library* , then review any
messages, the installation instructions, and see [Initializing
Node-oracledb][17].
2017-06-29 14:35:55 +08:00
2019-11-19 10:24:10 +08:00
- If you got *DPI-1072: the Oracle Client library version is unsupported* , then
review the installation requirements. Node-oracledb needs Oracle client
libraries 11.2 or later. Note that version 19 is not supported on Windows 7.
2019-11-19 10:20:43 +08:00
2017-07-08 10:48:36 +08:00
- Does your Node.js architecture (32-bit or 64-bit) match the Oracle
2017-07-11 10:41:54 +08:00
client library architecture? Run `node -p 'process.arch'` and
compare with, for example, `dumpbin /headers oci.dll` (on Windows),
`file libclntsh.dylib` (macOS) or `file libclntsh.so.*` (Linux).
2017-06-29 14:35:55 +08:00
2017-07-08 10:48:36 +08:00
- On Windows, do you have the correct VS Redistributable? Review
the [Windows install instructions ](#winredists ).
2017-06-29 14:35:55 +08:00
2017-08-16 13:09:09 +08:00
- On Windows, check the `PATH` environment variable includes the
Oracle client libraries. Ensure that you have restarted your
command prompt after you modified any environment variables.
2017-06-29 14:35:55 +08:00
2017-07-11 10:41:54 +08:00
- Do you need system privileges to set, or preserve, variables like
`PATH` , e.g. an elevated command prompt on Windows, or `sudo -E` on
Linux?
2017-07-08 10:48:36 +08:00
2017-06-29 14:35:55 +08:00
- Do you have multiple copies of Oracle libraries installed? Is the
2017-07-08 10:48:36 +08:00
expected version first in `PATH` (on Windows) or `LD_LIBRARY_PATH`
(on Linux)?
2020-05-20 20:50:36 +08:00
- On macOS, did you install Oracle Instant Client libraries in `/usr/local/lib` ?
2017-07-08 10:48:36 +08:00
2018-10-01 20:11:16 +08:00
Issues and questions about node-oracledb can be posted on [GitHub][10] or
[Slack][48] ([link to join Slack][49]).
2017-12-12 07:17:52 +08:00
2020-06-03 12:14:49 +08:00
[1]: https://github.com/oracle/node-oracledb/
2017-11-17 20:06:47 +08:00
[2]: https://www.python.org/downloads/
2019-11-25 10:14:39 +08:00
[3]: https://www.oracle.com/database/technologies/instant-client.html
2017-11-17 20:06:47 +08:00
[4]: https://www.npmjs.com/package/oracledb
[5]: https://blogs.oracle.com/opal/getting-a-c11-compiler-for-node-4,-5-and-6-on-oracle-linux-6
[6]: https://support.oracle.com/epmos/faces/DocumentDisplay?id=207303.1
2018-02-21 07:53:15 +08:00
[7]: https://oracle.github.io/node-oracledb/doc/api.html#connectionstrings
2017-11-17 20:06:47 +08:00
[8]: https://www.oracle.com/technetwork/community/oca-486395.html
[9]: https://www.github.com/oracle/odpi
[10]: https://github.com/oracle/node-oracledb/issues
[11]: http://nodejs.org
2019-11-25 10:14:39 +08:00
[12]: https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html
[13]: https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html#ic_x64_inst
2017-11-17 20:06:47 +08:00
[14]: https://linux.oracle.com
2019-03-13 07:53:57 +08:00
[15]: https://www.oracle.com/pls/topic/lookup?ctx=dblatest& id=GUID-7F967CE5-5498-427C-9390-4A5C6767ADAA
[16]: https://www.oracle.com/pls/topic/lookup?ctx=dblatest& id=GUID-2041545B-58D4-48DC-986F-DCC9D0DEC642
2020-06-03 12:14:49 +08:00
[17]: https://oracle.github.io/node-oracledb/doc/api.html#initnodeoracledb
2018-08-22 11:14:25 +08:00
[18]: https://www.oracle.com/pls/topic/lookup?ctx=dblatest& id=GUID-9D12F489-EC02-46BE-8CD4-5AECED0E2BA2
2017-11-17 20:06:47 +08:00
[19]: https://github.com/oracle/node-oracledb/tree/master/examples
2018-11-26 11:43:30 +08:00
[20]: https://www.oracle.com/database/technologies/appdev/xe.html
2017-11-17 20:06:47 +08:00
[21]: https://blogs.oracle.com/opal/the-easiest-way-to-install-oracle-database-on-apple-mac-os-x
2019-11-25 10:14:39 +08:00
[22]: https://www.oracle.com/database/technologies/instant-client/macos-intel-x86-downloads.html
2017-11-17 20:06:47 +08:00
[23]: https://docs.oracle.com/database/
2018-08-22 11:14:25 +08:00
[24]: https://www.oracle.com/pls/topic/lookup?ctx=dblatest& id=NTCLI
2019-11-25 10:14:39 +08:00
[25]: https://www.oracle.com/database/technologies/instant-client/winx64-64-downloads.html
[26]: https://www.oracle.com/database/technologies/instant-client/microsoft-windows-32-downloads.html
2017-12-12 06:56:12 +08:00
[27]: https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads
[29]: https://www.microsoft.com/en-us/download/details.aspx?id=3387
2019-11-25 10:14:39 +08:00
[30]: https://www.oracle.com/database/technologies/instant-client/aix-ppc64-downloads.html
[31]: https://www.oracle.com/database/technologies/instant-client/solx8664-downloads.html
2017-11-17 20:06:47 +08:00
[40]: https://github.com/oracle/node-oracledb/tags
[41]: https://github.com/oracle/node-oracledb/releases
2018-02-21 07:53:15 +08:00
[42]: https://oracle.github.io/node-oracledb/doc/api.html#migratev1v2
2017-12-12 07:03:15 +08:00
[43]: https://github.com/oracle/node-oracledb/blob/master/CHANGELOG.md
2018-02-21 07:53:15 +08:00
[44]: https://oracle.github.io/node-oracledb/doc/api.html
2018-02-06 10:39:51 +08:00
[45]: https://www.youtube.com/watch?v=WDJacg0NuLo
2018-02-09 17:33:44 +08:00
[46]: http://yum.oracle.com/oracle-linux-nodejs.html
2018-09-26 16:04:18 +08:00
[47]: https://oracle.github.io/node-oracledb/doc/api.html#migrate
2018-10-01 20:11:16 +08:00
[48]: https://node-oracledb.slack.com/
2019-11-19 10:20:16 +08:00
[49]: https://join.slack.com/t/node-oracledb/shared_invite/enQtNDU4Mjc2NzM5OTA2LWMzY2ZlZDY5MDdlMGZiMGRkY2IzYjI5OGU4YTEzZWM5YjQ3ODUzMjcxNWQyNzE4MzM5YjNkYjVmNDk5OWU5NDM
2018-12-23 06:52:34 +08:00
[50]: http://yum.oracle.com/repo/OracleLinux/OL6/oracle/instantclient/x86_64/index.html
[51]: http://yum.oracle.com/repo/OracleLinux/OL7/oracle/instantclient/x86_64/index.html
2019-03-13 08:02:49 +08:00
[53]: https://nodejs.org/api/n-api.html
2019-08-14 19:48:50 +08:00
[55]: https://github.com/oracle/node-oracledb/blob/v3.1.2/INSTALL.md
2019-11-25 10:14:39 +08:00
[56]: https://hub.docker.com/_/node/
[57]: https://oracle.github.io/node-oracledb/doc/api.html#connectionadb
2020-02-28 07:50:42 +08:00
[58]: https://oracle.github.io/node-oracledb/doc/api.html#tnsadmin
2019-11-25 10:14:39 +08:00
[59]: https://www.docker.com/
2020-02-28 07:50:42 +08:00
[60]: https://oracle.github.io/node-oracledb/doc/api.html#architecture
[61]: https://download.oracle.com/otn_software/linux/instantclient/instantclient-basic-linuxx64.zip
2020-06-03 12:12:53 +08:00
[62]: https://www.oracle.com/pls/topic/lookup?ctx=dblatest& id=GUID-81D364CE-326D-4B3C-8C82-F468FF1AF30C
2020-06-03 12:14:49 +08:00
[63]: https://github.com/oracle/node-oracledb/tree/master/examples/example.js
[64]: https://oracle.github.io/node-oracledb/doc/api.html#odbinitoracleclient
2020-06-25 07:38:09 +08:00
[65]: https://github.com/oracle/docker-images/tree/master/OracleLinuxDevelopers/oraclelinux7/nodejs
[66]: https://github.com/oracle/node-oracledb/blob/v4.2.0/INSTALL.md