i'm using Jest to test my server
on OSX
node version : v6.9.1
oracledb version : 1.12.0
gcc version : 4.2.1
error message is :
NJS-045: cannot load the oracledb add-on binary
at Object.<anonymous> (node_modules/oracledb/lib/oracledb.js:51:15)
I found oracledb.js line 35
oracledbCLib = require('../build/Release/oracledb');
But there is only node_module/oracledb/build/Release/oracledb.node in it
change oracledb.js line 35 to
oracledbCLib = require('../build/Release/oracledb.node');
it works
But I want to know is osx build problem or what?
I don't what to change the code after I build it every time
Does a non-Jest test script work? What did you run to install node-oracledb?
Hi, I have the same issue trying to use oracledb library with Node-Red.
16 Jan 15:12:58 - [warn] [oracledb] Error: NJS-045: cannot load the oracledb add-on binary
My env is a Mac too. By the way, I believe I followed all the steps in the install instructions.
I have also tried to use something different from node-red, and apparently it works. I got a diff error message related to a non existing database.
So, I am struggling to go over NJS-045 error. Any idea please ?
@giulianodm does a non-node red app (e.g example work? What if you set NODE_PATH to the node_modules directory?
Hi @cjbj . Yes it does work. See the trace below.
--> node select1.js
log -- /Users/giulianodm/node_modules/oracledb/lib
ORA-12154: TNS:could not resolve the connect identifier specified
PS.: The TNS error is because I don't have a proper OracleDB that I can use at the moment.
Can you do add some console.logs and check what the working directory etc are in both cases?
What if you set NODE_PATH?
Hi @cjbj
Actually NODE_PATH was not set. I just did it, and gave another try. Same NJS-045 error.
echo $NODE_PATH
/Users/giulianodm/node_modules
ls -la /Users/giulianodm/node_modules/
drwxr-xr-x 12 giulianodm staff 408 Jan 16 12:30 oracledb
ls -la /Users/giulianodm/node_modules/oracledb/
total 168
drwxr-xr-x 12 giulianodm staff 408 Jan 16 12:30 .
drwxr-xr-x 4 giulianodm staff 136 Jan 16 12:30 ..
-rw-r--r-- 1 giulianodm staff 18624 Dec 21 07:33 CHANGELOG.md
-rw-r--r-- 1 giulianodm staff 36585 Mar 24 2016 LICENSE.md
-rw-r--r-- 1 giulianodm staff 6110 Dec 12 23:33 README.md
-rw-r--r-- 1 giulianodm staff 11162 Aug 19 00:14 binding.gyp
drwxr-xr-x 8 giulianodm staff 272 Jan 16 12:30 build
-rw-r--r-- 1 giulianodm staff 47 Feb 28 2016 index.js
drwxr-xr-x 9 giulianodm staff 306 Jan 16 12:30 lib
drwxr-xr-x 3 giulianodm staff 102 Jan 16 12:30 node_modules
-rw-r--r-- 1 root staff 2033 Jan 16 12:30 package.json
drwxr-xr-x 4 giulianodm staff 136 Jan 16 12:30 src
Regarding the logs...
For the example code (node) that works:
node select1.js
0-/Users/giulianodm/node_modules/oracledb/lib
1-/Users/giulianodm/node_modules/oracledb/lib
ORA-12154: TNS:could not resolve the connect identifier specified
For the node-red:
node-red
0-/Users/giulianodm/node_modules/oracledb/lib
1-/Users/giulianodm/node_modules/oracledb/lib
17 Jan 11:15:52 - [info]
Welcome to Node-RED
17 Jan 11:15:52 - [info] Node-RED version: v0.16.0
17 Jan 11:15:52 - [info] Node.js version: v4.7.2
17 Jan 11:15:52 - [info] Darwin 16.3.0 x64 LE
17 Jan 11:15:53 - [info] Loading palette nodes
17 Jan 11:15:54 - [info] UI started at /ui
17 Jan 11:15:54 - [warn] ------------------------------------------------------
17 Jan 11:15:54 - [warn] [rpi-gpio] Info : Ignoring Raspberry Pi specific node
17 Jan 11:15:54 - [warn] [oracledb] Error: NJS-045: cannot load the oracledb add-on binary
17 Jan 11:15:54 - [warn] ------------------------------------------------------
17 Jan 11:15:54 - [info] Settings file : /Users/giulianodm/.node-red/settings.js
17 Jan 11:15:54 - [info] User directory : /Users/giulianodm/.node-red
17 Jan 11:15:54 - [info] Flows file : /Users/giulianodm/.node-red/flows_Giulianos-MacBook-Pro-2.local.json
17 Jan 11:15:54 - [info] Creating new flow file
17 Jan 11:15:54 - [debug] loaded flow revision: 513fd923d68021b8ee98fcb250470340
17 Jan 11:15:54 - [debug] red/runtime/nodes/credentials.load : no user key present
17 Jan 11:15:54 - [debug] red/runtime/nodes/credentials.load : using default key
17 Jan 11:15:54 - [info] Starting flows
17 Jan 11:15:54 - [info] Started flows
17 Jan 11:15:54 - [info] Server now running at http://127.0.0.1:1880/
FYI - This is the code I've added the log - oracledb.js
`console.log("0-" +__dirname);
try {
oracledbCLib = require('../build/Release/oracledb');
console.log("1-" + __dirname);
} catch (err) {
if (err.code !== 'MODULE_NOT_FOUND') {
console.log("2-" +__dirname);
throw err;
} else {
try {
console.log("3-" + __dirname);
oracledbCLib = require('../build/Debug/oracledb');
console.log("4-" +__dirname);
} catch (err) {
console.log("5-" +__dirname);
if (err.code !== 'MODULE_NOT_FOUND') {
throw err;
} else {
console.log("6-" +__dirname);
throw new Error(nodbUtil.getErrorMessage('NJS-045'));
}
}
}
}`
This slipped past the keeper, did you get any further with it?
I fix it by change oracledb.js line 35
@yushanhsieh what did you change on line 35
@waleedahmed3045
I changed oracledb.js line 35 to
oracledbCLib = require('../build/Release/oracledb.node');
original line is
oracledbCLib = require('../build/Release/oracledb');
@yushanhsieh @waleedahmed3045 is this use of oracledbCLib = require('../build/Release/oracledb.node'); confirmed? Any thoughts about what is going on? Do you have multiple installs/builds? Where are you getting Node from? I'm asking so we can assess whether to patch node-oracledb
I resolved this error by running npm rebuild oracledb...
Steps to replicate issue:
1) Follow default oracledb, jest, and ts-jest setup instructions.
2) Implement simple.test.ts:
import * as oracledb from "oracledb";
test("oracle imports", () => {
expect(oracledb).toBeDefined();
});
3) jest results:
FAIL src/simple.test.ts
● Test suite failed to run
NJS-045: cannot load the oracledb add-on binary
at Object.<anonymous> (node_modules/oracledb/lib/oracledb.js:46:15)
at Object.<anonymous> (node_modules/oracledb/index.js:1:45)
at Object.<anonymous> (src/simple.test.ts:1:1)
at next (native)
at next (native)
at process._tickCallback (internal/process/next_tick.js:109:7)
Notes:
npm rebuild oracledb does not resolve this issue.oracledbCLib = require('../build/Release/oracledb.node'); from above does work: PASS src/simple.test.ts@derrickbabb thanks for posting your solution. It would be nice to know why standard Node name resolution isn't working. The node-oracledb v2 driver gives some more heuristics which may help narrow this down in future.
Hi all,
I've lost a couple of days to solve this issue in my Windows environment, so I am posting this to help anyone that may end up having the same problem.
Even if you already have some Visual C++ Build Tools installed (e.g. 2015 in my case), make sure to install too the appropiate VS Redistributable for your oracle version.
In my case (Oracle Instant Client 12.2), I had to install the Build Tools 2013.
After doing so, I do not need to modify the '../build/Release/oracledb.node' path
I was able to reproduce the issue folowing @derrickbabb steps. However, setting the oracledbCLib path to '../build/Release/oracledb' (currently at line 33) would not resolve the issue for me.
I am running the test in a 64-bits Windows 10, and this is the stack trace I was getting:
Based on the error message, here are some more details of my environment:
npm install --global --production windows-build-toolsEverything seemed to be fine, but since I was missing the appropriate VS Redistributable version, the oracle.node binary was not being successfully loaded.
I finally saw that in the installation instructions, but it took me ages because the error message is not very precise about it.
I don't pretend to justify my lack of attention to the install instructions, but may be the error handling could be a bit more concrete.
Thanks
@basalter I appreciate the post, and can hear your frustration.
If you have specific wording or layout suggestions, send them through. The instructions keep getting tuned and the bootstrap error messages can always be changed.
I can also edit the Instant Client download page directly, if you don't think they spell out which redistributable to install.
@cjbj The instant client download page is fine :)
About the error messages, I guess it is not that easy to improve the wording. In my case, what had been useful would be that the exception raised when requiring the library
oracledbCLib = require(binaryReleasePath);
mentioned the fact that the VS Redistributable is not installed (stating the version required) rather than just saying 'DPI-1047: 64-bit Oracle Client library cannot be loaded'. I imagine that this exception has nothing to do with the node package though
@basalter Improvements would require some heuristics to interrogate what is installed, and what versions. I'm not a Windows user. Can you submit a PR or some code snippets?
[For future readers, note that for node-oracledb 2 installation on Windows there are pre-built binaries available for current Node versions so you don't need a compiler and don't need to set to OCI_VERSION, OCI_LIB_DIR or OCI_INC_DIR: see the [instructions](https://oracle.github.io/node-oracledb/INSTALL.html#instwin)]
I got reserved the issue.
just uninstall visual studio greater than 2013 then install only vs2013
https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads
On Unix machine, i got this issue fixed by creating symbolic link for oracle client in /usr/local/lib
ln -s /opt/oracle/instantclient/libclntsh.dylib libclntsh.dylib
@benamrou you probably mean on macOS, since dylib files are not used on Linux.
That’s correct. (On MacOS).
On Sep 22, 2018, at 3:55 PM, Christopher Jones notifications@github.com wrote:
@benamrou https://github.com/benamrou you probably mean on macOS, since dylib files are not used on Linux.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/oracle/node-oracledb/issues/577#issuecomment-423779096, or mute the thread https://github.com/notifications/unsubscribe-auth/AAXoLVChkW5qXQKMFfIhiUkPRwT47hZaks5udr_2gaJpZM4LXT-D.
I have the same issue on Windows 10. But its while debugging only, not when I do npm start.
You must have 64-bit Oracle client libraries in your PATH environment variable.
If you do not have Oracle Database on this computer, then install the Instant Client Basic or Basic Light package from
http://www.oracle.com/technetwork/topics/winx64soft-089540.html
A Microsoft Visual Studio Redistributable suitable for your Oracle client library version must be available.
at Object.
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.
at Module._compile (module.js:652:30)

how to install oracledb here
@Renu353 This is a closed issue and your request isn't clear to me. Please open a new issue and make sure you give enough information so people can help. Also read https://oracle.github.io/node-oracledb/INSTALL.html
I had the same issue with my dev environment. It got resolved after mentioned instantclient path in environment variable.
OS : Windows
Command
IF EXIST E:\Users...\instantclient SET PATH=%PATH%;E:\Users...\instantclient
I am getting the same error.
[root@xmalaiapp-as-1p API]# /usr/bin/node /xmalai_fs/API/serverAPI.js
/xmalai_fs/API/node_modules/oracledb/lib/oracledb.js:68
throw new Error(nodbUtil.getErrorMessage('NJS-045', nodeInfo));
^
Error: NJS-045: cannot load the oracledb add-on binary for Node.js 11.10.1 (linux, x64)
Cannot load /xmalai_fs/API/node_modules/oracledb/build/Release/oracledb.node
/xmalai_fs/API/node_modules/oracledb/build/Release/oracledb.node: invalid ELF header
Node-oracledb installation instructions: https://oracle.github.io/node-oracledb/INSTALL.html
You must have 64-bit Oracle client libraries in LD_LIBRARY_PATH, or configured with ldconfig.
If you do not have Oracle Database on this computer, then install the Instant Client Basic or Basic Light package from
http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
at Object.<anonymous> (/xmalai_fs/API/node_modules/oracledb/lib/oracledb.js:68:13)
at Module._compile (internal/modules/cjs/loader.js:738:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:749:10)
at Module.load (internal/modules/cjs/loader.js:630:32)
at tryModuleLoad (internal/modules/cjs/loader.js:570:12)
at Function.Module._load (internal/modules/cjs/loader.js:562:3)
at Module.require (internal/modules/cjs/loader.js:667:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/xmalai_fs/API/node_modules/oracledb/index.js:1:80)
at Module._compile (internal/modules/cjs/loader.js:738:30)
Could any one help me on this.
I am getting the same error.
[root@xmalaiapp-as-1p API]# /usr/bin/node /xmalai_fs/API/serverAPI.js
/xmalai_fs/API/node_modules/oracledb/lib/oracledb.js:68
throw new Error(nodbUtil.getErrorMessage('NJS-045', nodeInfo));
^Error: NJS-045: cannot load the oracledb add-on binary for Node.js 11.10.1 (linux, x64)
Cannot load /xmalai_fs/API/node_modules/oracledb/build/Release/oracledb.node
/xmalai_fs/API/node_modules/oracledb/build/Release/oracledb.node: invalid ELF header
Node-oracledb installation instructions: https://oracle.github.io/node-oracledb/INSTALL.html
You must have 64-bit Oracle client libraries in LD_LIBRARY_PATH, or configured with ldconfig.
If you do not have Oracle Database on this computer, then install the Instant Client Basic or Basic Light package from
http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.htmlat Object.<anonymous> (/xmalai_fs/API/node_modules/oracledb/lib/oracledb.js:68:13) at Module._compile (internal/modules/cjs/loader.js:738:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:749:10) at Module.load (internal/modules/cjs/loader.js:630:32) at tryModuleLoad (internal/modules/cjs/loader.js:570:12) at Function.Module._load (internal/modules/cjs/loader.js:562:3) at Module.require (internal/modules/cjs/loader.js:667:17) at require (internal/modules/cjs/helpers.js:20:18) at Object.<anonymous> (/xmalai_fs/API/node_modules/oracledb/index.js:1:80) at Module._compile (internal/modules/cjs/loader.js:738:30)Could any one help me on this.
Hi yogesh, this request is closed, it is 2 years old in fact and several of the problems seen here do not apply to current version of the module.
Can you please open a new issue in case you need support by following the requested template and also take a look on https://oracle.github.io/node-oracledb/INSTALL.html
Most helpful comment
I resolved this error by running
npm rebuild oracledb...