diff --git a/lib/oracledb.js b/lib/oracledb.js index d2f3a429b..3dc277eba 100644 --- a/lib/oracledb.js +++ b/lib/oracledb.js @@ -22,6 +22,9 @@ var oracledbInst; var Lob = require('./lob.js').Lob; var pool = require('./pool.js'); var connection = require('./connection.js'); +var path; +var fs; +var fileExists; try { oracledbCLib = require('../build/Release/oracledb'); @@ -29,6 +32,39 @@ try { if (err.code === 'MODULE_NOT_FOUND') { oracledbCLib = require('../build/Debug/oracledb'); } else { + path = require('path'); + fs = require('fs'); + + fileExists = function(fullPathToFile) { + try { + return fs.statSync(fullPathToFile).isFile(); + } + catch (err) { + return false; + } + }; + + process.env.PATH.split(path.delimiter).forEach(function(dir) { + var msg = function(){ + console.log(); + console.log('**** Found an Oracle client library in PATH in the following directory: ' + dir); + console.log('**** But the version is either corrupt or not for the same OS and/or Node.js processor architecture in which you\'re running on.'); + console.log('**** Your Node.js processor architecture is ' + process.arch + '.'); + console.log('**** If you have multiple Oracle client directories defined in PATH, only the first one is loaded.'); + console.log('**** Therefore, the first to appear needs to be correct one.'); + console.log(); + throw err; + }; + + if(fileExists(path.join(dir, 'oci.dll'))) {msg();} + + }); + + console.log(); + console.log('****'); + console.log('**** AN ORACLE CLIENT LIBRARY WAS NOT FOUND.'); + console.log('****'); + console.log(); throw err; } }