Node-oracledb: NJS-069 node-oracledb 4.0.1 requires Node.js 8.16 or later in vuetify app

Created on 1 Nov 2019  路  4Comments  路  Source: oracle/node-oracledb

Hello folks!

  1. What is your Oracle Database version?
    11.2

my test script works pretty well:

[andreas@oc3207008144 oratest]$ cat readhost.js
const oracledb = require('oracledb');
async function getHost(hostid) {
let conn;
var dbConfig = {
user: "XXXXX",
password: "YYYYYY",
connectString: "ibmtarcms.test.de.sni.ibm.com/rcm",
externalAuth: false
}

try {
    console.log("Loggin in to RCM with " + dbConfig.user + "/" + dbConfig.password);
    conn = await oracledb.getConnection(dbConfig);
    sql = 'select TO_CHAR(hostid) as HOSTID from rcm.host where hostid = :id';
    const result = await conn.execute( sql, [hostid]);
    console.log('Result:', result.metaData[0]);
    console.log('Result: result.rows[0][0] : ', result.rows[0][0]);
} catch (err) {
    console.log('Ouch!', err);
} finally {
    if (conn) { // conn assignment worked, need to close
        await conn.close();
    }
}

}
var infos = "Platform: " + process.platform + "|Version: "+ process.version + "|Arch: " + process.arch + "|Oracledb-Version: " + require('oracledb').versionString;
console.log(infos);
getHost('ibmprcm01.ffm.de.sni.ibm.com');

andreas@oc3207008144 oratest]$ node readhost.js
Platform: linux|Version: v12.10.0|Arch: x64|Oracledb-Version: 4.0.1
Loggin in to RCM with xtrnrhr/androh2019
Result: { name: 'HOSTID' }
Result: result.rows[0][0] : ibmprcm01.ffm.de.sni.ibm.com
[andreas@oc3207008144 oratest]$

However, when i try to use the oracledb module in a vuetify app i receive above error.
I tried to use in the methods section where defined the call backup function 'submit' of a button (v-bnt):

Login

10 methods: {
11 async submit() {
12 let conn;
13 if(this.$refs.form.validate()) {
14 this.$emit('changeStatus',"Think!");
16 var infos = "Platform: " + process.platform + "|Version: "+ process.version + "|Arch: " + process.arch;
17 this.$emit('changeStatus', infos);
19 const oracledb = require('oracledb');
20 this.$emit('changeStatus',"Think twice!");

Actually the process attribute is not initialized or available.
It compiles and starts the webserver:
[andreas@oc3207008144 src]$ npm run serve

[email protected] serve /home/andreas/nodejs/ispnodevuetify/ispnode
vue-cli-service serve
INFO Starting development server...
98% after emitting CopyPlugin
WARNING Compiled with 1 warnings warning in /home/andreas/nodejs/node_modules/oracledb/lib/oracledb.js
Critical dependency: the request of a dependency is an expression
App running at:

... but as a result of line 17 I see on the web page:
Platform: undefined|Version: |Arch: undefined"

Maybe I have to define / import the oracledb somewhere else in the script?

I hope sb has an idea!
Thx in advance!
Cheers,
Andreas

question

Most helpful comment

As far as I can tell, vuetify is a front-end library that adds Material Design components to a Vue project. Node-oracledb is a Node.js mid-tier application. These are different types of applications.

Typically, one would use node-oracledb to create a REST API, as discussed here: https://jsao.io/2018/03/creating-a-rest-api-with-node-js-and-oracle-database/

Then the front-end app will consume the REST API.

All 4 comments

As far as I can tell, vuetify is a front-end library that adds Material Design components to a Vue project. Node-oracledb is a Node.js mid-tier application. These are different types of applications.

Typically, one would use node-oracledb to create a REST API, as discussed here: https://jsao.io/2018/03/creating-a-rest-api-with-node-js-and-oracle-database/

Then the front-end app will consume the REST API.

Hi Dan, thx a lot, that brought me a thousand miles further :-)
Next step is to implement authentication into the rest api ... any hint for that also?
Cheers,
Andreas

I wrote a post on that before the REST series:
https://jsao.io/2015/06/authentication-with-node-js-jwts-and-oracle-database/

Unfortunately, the code is a bit older and less refined. But you should be able to integrate the concepts into the REST API code base without too much effort.

I wrote a newer post that uses Oracle's Identity Cloud Service rather than custom tables. This is nice in that it reduces risk on your end. This code is integrated with the REST API series.
https://jsao.io/2019/08/authenticating-end-users-with-node-js-and-oracle-identity-cloud-service/

Closing - no update

Was this page helpful?
0 / 5 - 0 ratings