@@ -41,28 +41,32 @@ var binaryDebugPath = '../build/Debug/oracledb.node';
41
41
try {
42
42
oracledbCLib = require ( binaryReleasePath ) ;
43
43
} catch ( err ) {
44
- if ( err . code !== 'MODULE_NOT_FOUND' ) {
45
- throw err ;
46
- } else {
44
+ var nodeInfo = process . versions . node + ' (' + process . platform + ', ' + process . arch + ')\n' ;
45
+ var fullReleasePath = require ( 'path' ) . resolve ( __dirname , binaryReleasePath ) ;
46
+ if ( err . code === 'MODULE_NOT_FOUND' ) {
47
47
try {
48
48
oracledbCLib = require ( binaryDebugPath ) ;
49
49
} catch ( err ) {
50
- if ( err . code !== 'MODULE_NOT_FOUND' ) {
51
- throw err ;
50
+ if ( err . code === 'MODULE_NOT_FOUND' ) {
51
+ // Neither Release or Debug binary was found but assume users wanted Release binary
52
+ nodeInfo += 'Cannot find module ' + fullReleasePath + '\n' + getInfo ( ) ;
53
+ throw new Error ( nodbUtil . getErrorMessage ( 'NJS-045' , nodeInfo ) ) ;
52
54
} else {
53
- var nodeInfo = process . versions . node + ' (' + process . platform + ', ' + process . arch + ')\n' ;
54
- var fullPath = require ( 'path' ) . resolve ( __dirname , binaryReleasePath ) ;
55
- try {
56
- require ( 'fs' ) . statSync ( fullPath ) ;
57
- nodeInfo += getInfo ( ) ; // file exists, so get message about Oracle Client
58
- throw new Error ( nodbUtil . getErrorMessage ( 'NJS-045' , nodeInfo ) ) ;
59
- } catch ( err ) {
60
- // file couldn't be found
61
- nodeInfo += 'Cannot read ' + fullPath + '\n' + err . message ;
62
- throw new Error ( nodbUtil . getErrorMessage ( 'NJS-045' , nodeInfo ) ) ;
63
- }
55
+ nodeInfo += 'Cannot load ' + binaryDebugPath + '\n' ;
56
+ nodeInfo += 'Node.js require() error was: \n ' + err . message + '\n' + getInfo ( ) ;
57
+ throw new Error ( nodbUtil . getErrorMessage ( 'NJS-045' , nodeInfo ) ) ;
64
58
}
65
59
}
60
+ } else {
61
+ if ( err . message . startsWith ( 'DPI-1047:' ) ) {
62
+ // Release add-on binary loaded OK, but ODPI-C can't load Oracle client
63
+ nodeInfo += 'Node.js require() error was: \n ' + err . message + '\n' ;
64
+ nodeInfo += 'Node.js require() mapped to ' + fullReleasePath + '\n' + getInfo ( ) ;
65
+ throw new Error ( nodbUtil . getErrorMessage ( 'NJS-045' , nodeInfo ) ) ;
66
+ } else {
67
+ nodeInfo += 'Cannot load ' + fullReleasePath + '\n' + err . message + '\n' + getInfo ( ) ;
68
+ throw new Error ( nodbUtil . getErrorMessage ( 'NJS-045' , nodeInfo ) ) ;
69
+ }
66
70
}
67
71
}
68
72
@@ -72,9 +76,10 @@ oracledbCLib.Oracledb.prototype.newLob = function(iLob) {
72
76
73
77
74
78
// Return a string with installation usage tips that may be helpful
75
- // (although ODPI-C should catch most cases)
76
79
function getInfo ( ) {
77
80
var arch , url , mesg = '' ;
81
+ mesg = 'Node-oracledb installation instructions: ' ;
82
+ mesg += 'https://github.com/oracle/node-oracledb/blob/master/INSTALL.md\n' ;
78
83
if ( process . platform === 'linux' ) {
79
84
if ( process . arch === 'x64' ) {
80
85
url = 'http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html\n' ;
@@ -84,14 +89,13 @@ function getInfo() {
84
89
arch = '32-bit' ;
85
90
}
86
91
mesg += 'You must have ' + arch + ' Oracle client libraries in LD_LIBRARY_PATH, or configured with ldconfig.\n' ;
87
- mesg += 'If you do not already have libraries, install the Instant Client Basic or Basic Light package from \n' ;
92
+ mesg += 'If you do not have Oracle Database on this computer, then install the Instant Client Basic or Basic Light package from \n' ;
88
93
mesg += url ;
89
94
} else if ( process . platform === 'darwin' ) {
95
+ url = 'http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html' ;
90
96
if ( process . arch === 'x64' ) {
91
- url = 'http://www.oracle.com/technetwork/topics/winx64soft-089540.html' ;
92
97
arch = '64-bit' ;
93
98
} else {
94
- url = 'http://www.oracle.com/technetwork/topics/winsoft-085727.html' ;
95
99
arch = '32-bit' ;
96
100
}
97
101
mesg += 'You must have the ' + arch + ' Oracle Instant Client Basic or Basic Light package in ~/lib or /usr/local/lib\n' ;
@@ -105,7 +109,7 @@ function getInfo() {
105
109
arch = '32-bit' ;
106
110
}
107
111
mesg += 'You must have ' + arch + ' Oracle client libraries in your PATH environment variable.\n' ;
108
- mesg += 'If you do not already have libraries, install the Instant Client Basic or Basic Light package from\n' ;
112
+ mesg += 'If you do not have Oracle Database on this computer, then install the Instant Client Basic or Basic Light package from\n' ;
109
113
mesg += url ;
110
114
mesg += 'A Microsoft Visual Studio Redistributable suitable for your Oracle client library version must be available.\n' ;
111
115
} else {
@@ -116,11 +120,9 @@ function getInfo() {
116
120
arch = '32-bit' ;
117
121
}
118
122
mesg += 'You must have ' + arch + ' Oracle client libraries in your operating system library search path.\n' ;
119
- mesg += 'If you do not already have libraries, install an Instant Client Basic or Basic Light package from: \n' ;
123
+ mesg += 'If you do not have Oracle Database on this computer, then install an Instant Client Basic or Basic Light package from: \n' ;
120
124
mesg += url ;
121
125
}
122
- mesg += 'Node-oracledb installation instructions: ' ;
123
- mesg += 'https://github.com/oracle/node-oracledb/blob/master/INSTALL.md\n\n' ;
124
126
return mesg ;
125
127
}
126
128
0 commit comments