diff --git a/README.md b/README.md index 2e6923b1..31515ef4 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,9 @@ The node-oracledb add-on for Node.js powers high performance Oracle Database applications. Applications can be written in TypeScript, or directly in JavaScript. -Use node-oracledb 6.0.0-dev to connect Node.js 14, or later, to Oracle Database. -Older versions of node-oracledb may work with older versions of Node.js. +Use node-oracledb 6.0.0-dev to connect Node.js 14.6, or later, to Oracle +Database. Older versions of node-oracledb may work with older versions of +Node.js. Node-oracledb supports basic and advanced features of Oracle Database and Oracle Client. See the [homepage][4] for a list. diff --git a/lib/oracledb.js b/lib/oracledb.js index 08772098..2700d3a0 100644 --- a/lib/oracledb.js +++ b/lib/oracledb.js @@ -32,12 +32,15 @@ const errors = require('./errors.js'); const impl = require('./impl'); const util = require('util'); -// This version of node-oracledb works with Node.js 14 or later. The test -// stops hard-to-interpret runtime errors and crashes with older Node.js -// versions. -let vs = process.version.substring(1).split(".").map(Number); -errors.assert(vs[0] >= 14, errors.ERR_NODE_TOO_OLD, - nodbUtil.PACKAGE_JSON_VERSION, "14.0"); +// This version of node-oracledb works with Node.js 14.6 or later. +// Note: the checked version is the minimum required for Node-API +// compatibility. When new Node.js versions are released, older Node.js +// versions are dropped from the node-oracledb test plan. +// +// Keep this code in sync with package/install.js +const vs = process.version.substring(1).split(".").map(Number); +errors.assert(vs[0] > 14 || (vs[0] === 14 && vs[1] >= 6), + errors.ERR_NODE_TOO_OLD, nodbUtil.PACKAGE_JSON_VERSION, "14.6"); const AqDeqOptions = require('./aqDeqOptions.js'); const AqEnqOptions = require('./aqEnqOptions.js'); @@ -65,38 +68,42 @@ let _initOracleClientArgs; // Load the Oracledb binary +function _initCLib() { + /*global __non_webpack_require__*/ // quieten eslint + const requireBinary = (typeof __non_webpack_require__ === 'function') ? __non_webpack_require__ : require; // See Issue 1156 -/*global __non_webpack_require__*/ // quieten eslint -const requireBinary = (typeof __non_webpack_require__ === 'function') ? __non_webpack_require__ : require; // See Issue 1156 - -const binaryLocations = [ - '../' + nodbUtil.RELEASE_DIR + '/' + nodbUtil.BINARY_FILE, // pre-built binary - '../' + nodbUtil.RELEASE_DIR + '/' + 'oracledb.node', // binary built from source - '../build/Debug/oracledb.node', // debug binary - // For Webpack. A Webpack copy plugin is still needed to copy 'node_modules/oracledb/build/' to the output directory - // See https://github.com/oracle/node-oracledb/issues/1156 - './node_modules/oracledb/' + nodbUtil.RELEASE_DIR + '/' + nodbUtil.BINARY_FILE, - './node_modules/oracledb/' + nodbUtil.RELEASE_DIR + '/' + 'oracledb.node' -]; - -let oracledbCLib; -for (let i = 0; i < binaryLocations.length; i++) { - try { - oracledbCLib = requireBinary(binaryLocations[i]); - break; - } catch (err) { - if (err.code !== 'MODULE_NOT_FOUND' || i == binaryLocations.length - 1) { - let nodeInfo; - if (err.code === 'MODULE_NOT_FOUND') { - // A binary was not found in any of the search directories. - // Note this message may not be accurate for Webpack users since Webpack changes __dirname - nodeInfo = `\n Looked for ${binaryLocations.map(x => require('path').resolve(__dirname, x)).join(', ')}\n ${nodbUtil.getInstallURL()}\n`; - } else { - nodeInfo = `\n Node.js require('oracledb') error was:\n ${err.message}\n ${nodbUtil.getInstallHelp()}\n`; + const binaryLocations = [ + '../' + nodbUtil.RELEASE_DIR + '/' + nodbUtil.BINARY_FILE, // pre-built binary + '../' + nodbUtil.RELEASE_DIR + '/' + 'oracledb.node', // binary built from source + '../build/Debug/oracledb.node', // debug binary + // Paths for Webpack. + // Note: to use node-oracledb Thick mode, you will need a Webpack copy plugin to + // copy 'node_modules/oracledb/build/' to the output directory, + // see https://github.com/oracle/node-oracledb/issues/1156 + // If you want to use only node-oracledb Thin mode, a copy plugin is not needed. + './node_modules/oracledb/' + nodbUtil.RELEASE_DIR + '/' + nodbUtil.BINARY_FILE, + './node_modules/oracledb/' + nodbUtil.RELEASE_DIR + '/' + 'oracledb.node' + ]; + let oracledbCLib; + for (let i = 0; i < binaryLocations.length; i++) { + try { + oracledbCLib = requireBinary(binaryLocations[i]); + break; + } catch (err) { + if (err.code !== 'MODULE_NOT_FOUND' || i == binaryLocations.length - 1) { + let nodeInfo; + if (err.code === 'MODULE_NOT_FOUND') { + // A binary was not found in any of the search directories. + // Note this message may not be accurate for Webpack users since Webpack changes __dirname + nodeInfo = `\n Looked for ${binaryLocations.map(x => require('path').resolve(__dirname, x)).join(', ')}\n ${nodbUtil.getInstallURL()}\n`; + } else { + nodeInfo = `\n Node.js require('oracledb') error was:\n ${err.message}\n ${nodbUtil.getInstallHelp()}\n`; + } + errors.throwErr(errors.ERR_CANNOT_LOAD_BINARY, nodeInfo); } - errors.throwErr(errors.ERR_CANNOT_LOAD_BINARY, nodeInfo); } } + return oracledbCLib; } // top-level functions @@ -551,6 +558,7 @@ function initOracleClient(arg1) { errors.assertParamPropString(options, 1, "driverName"); } if (_initOracleClientArgs === undefined) { + const oracledbCLib = _initCLib(); if (options.driverName === undefined) options.driverName = constants.DEFAULT_DRIVER_NAME; if (options.errorUrl === undefined) diff --git a/package/install.js b/package/install.js index 68405a69..969dff83 100644 --- a/package/install.js +++ b/package/install.js @@ -1,4 +1,4 @@ -/* Copyright (c) 2017, 2022, Oracle and/or its affiliates. */ +/* Copyright (c) 2017, 2023, Oracle and/or its affiliates. */ /****************************************************************************** * @@ -41,8 +41,9 @@ const fs = require('fs'); const nodbUtil = require('../lib/util.js'); const errors = require('../lib/errors.js'); +const constants = require('../lib/constants.js'); -let installUrl = 'https://oracle.github.io/node-oracledb/INSTALL.html'; +let installUrl = constants.DEFAULT_ERROR_URL; let arch; let thickModeErrMsg; @@ -67,15 +68,16 @@ function warn(message) { // eslint-disable-line console.error.apply(console, args); } -// Check for the minimum version of Node.js. -// Version 14 (with Node-API 6), or later, is usable. -// Note that the checked version is the minimum required for Node-API +// This version of node-oracledb works with Node.js 14.6 or later. +// Note: the checked version is the minimum required for Node-API // compatibility. When new Node.js versions are released, older Node.js // versions are dropped from the node-oracledb test plan. +// +// Keep this code in sync with lib/oracledb.js function checkVersion() { const vs = process.version.substring(1).split(".").map(Number); - errors.assert(vs[0] >= 14, errors.ERR_NODE_TOO_OLD, - nodbUtil.PACKAGE_JSON_VERSION, "14.0"); + errors.assert(vs[0] > 14 || (vs[0] === 14 && vs[1] >= 6), + errors.ERR_NODE_TOO_OLD, nodbUtil.PACKAGE_JSON_VERSION, "14.6"); } // Check for the binary node-oracledb module needed for "Thick mode". @@ -113,11 +115,11 @@ if (process.arch === 'x64' || process.arch === 'arm64') { } if (process.platform === 'linux') { - installUrl += '#linuxinstall'; + installUrl += '#node-oracledb-installation-on-linux'; } else if (process.platform === 'darwin') { - installUrl += '#instosx'; + installUrl += '#node-oracledb-installation-on-apple-macos-intel-x86'; } else if (process.platform === 'win32') { - installUrl += '#windowsinstallation'; + installUrl += '#node-oracledb-installation-on-microsoft-windowsstallation'; } log('********************************************************************************');