Skip to content

Better error msg when Instant Client is missing #404

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions lib/oracledb.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,49 @@ 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');
} catch (err) {
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;
}
}
Expand Down