oracle / node-oracledb

Oracle Database driver for Node.js maintained by Oracle Corp.
http://oracle.github.io/node-oracledb/
Other
2.25k stars 1.07k forks source link

Cypress: NJS-069: node-oracledb 6.0.3 requires Node.js 14.6 or later. #1596

Closed labkapapka closed 1 year ago

labkapapka commented 1 year ago

Hi! I have problem with node-oracledb. When I launch my test-case in Cypress - I get error: NJS-069: node-oracledb 6.0.3 requires Node.js 14.6 or later. But my current version: oracledb@6.0.3 Node JS version v18.16.0

Cypress package version: 12.17.4 Cypress binary version: 12.17.4 Electron version: 21.0.0 Bundled Node version: 16.16.0 Could you help me solve the problem?

  1. What versions are you using?
  1. Is it an error or a hang or a crash?

  2. What error(s) or behavior you are seeing?

  1. Include a runnable Node.js script that shows the problem.
sharadraju commented 1 year ago

Hi, Please provide a running test case, that describes the problem. Also, is this a new test case or did you run it with earlier node-oracledb versions?

sudarshan12s commented 1 year ago

@labkapapka , It looks like the process which ran the test case used older node.js version ? Can you confirm if there are multiple node.js versions on your host and somehow Cypress tests points to older versions (<14.6) .. You can verify once by calling console.log(process.versions.node) from Cypress tests before loading oracledb module ? Can you also share the output of node example/version.js . We use process.version to detect the node version .

labkapapka commented 1 year ago

@labkapapka , It looks like the process which ran the test case used older node.js version ? Can you confirm if there are multiple node.js versions on your host and somehow Cypress tests points to older versions (<14.6) .. You can verify once by calling console.log(process.versions.node) from Cypress tests before loading oracledb module ? Can you also share the output of node example/version.js . We use process.version to detect the node version .

Hm, i get 'undefined' when try calling console.log(process.versions.node) from Cypress test before loading oracledb module. The output of `node example/version.js is Node.js v18.16.0

sudarshan12s commented 1 year ago

@labkapapka , It looks like the process which ran the test case used older node.js version ? Can you confirm if there are multiple node.js versions on your host and somehow Cypress tests points to older versions (<14.6) .. You can verify once by calling console.log(process.versions.node) from Cypress tests before loading oracledb module ? Can you also share the output of node example/version.js . We use process.version to detect the node version .

Hm, i get 'undefined' when try calling console.log(process.versions.node) from Cypress test before loading oracledb module. The output of `node example/version.js is Node.js v18.16.0

You have imported process in the file like below , where you have called? It is part of node.js process module const process = require('process');

labkapapka commented 1 year ago

Yes, but result the same. image

sudarshan12s commented 1 year ago

Can you try console.log(process.version); which we used inside driver (lib/oracledb.js) . It looks like inside Cypress tests, the same property process.version got overwritten as standalone (examples/version.js) works fine ? Can you cross check ?. Does an explicit const process =require('node:process'); ``help ?

labkapapka commented 1 year ago

I'm no shure that I can. I just start to write tests on JS + Cypress. Which code and where i should to run?

I'm no shure that I can. I just start to write tests on JS + Cypress. Which code and where i should to run? Could you help me?

labkapapka commented 1 year ago

Can you try console.log(process.version); which we used inside driver (lib/oracledb.js) . It looks like inside Cypress tests, the same property process.version got overwritten as standalone (examples/version.js) works fine ? Can you cross check ?. Does an explicit const process =require('node:process'); ``help ?

//oracledb.js 'use strict';

const constants = require('./constants.js'); const nodbUtil = require('./util.js'); const errors = require('./errors.js'); const types = require('./types.js'); const impl = require('./impl'); const process = require('process'); const util = require('util');

sudarshan12s commented 1 year ago

I mean inside the Cypress test files, can you add this piece of code and let me know the result.

   {
      const process = require('node:process');
    console.log(process.version);
    }
labkapapka commented 1 year ago

I mean inside the Cypress test files, can you add this piece of code and let me know the result.

   {
      const process = require('node:process');
    console.log(process.version);
    }

if i add this piece of code i get: image

labkapapka commented 1 year ago

//test.cy.js describe('TOKINIZER 3DS', () => { const process = require('node:process'); console.log(process.version); // const process = require('process'); // console.log(process.versions.node); it('Ord.1, Tokinizer, LOOK UP, MC,', () => { // const process = require('process'); // console.log(process.versions.node); const oracledb = require('oracledb');

oracledb.outFormat = oracledb.OUT_FORMAT_OBJECT;

async function run() {

const connection = await oracledb.getConnection ({
    user          : "admin",
    password      : "admin!",
    connectString : "b0t.test.local:1521/tzw1pgttest.local"
});

const result = await connection.execute(
    `SELECT *
     FROM PTEMPDATA`,
      // bind value for :id
);

console.log(result.rows);
await connection.close();

}

run(); }); });

sudarshan12s commented 1 year ago

I see your Cypress environment cant access node modules as it is . Your tests passed with previous versions like oracledb@5.5?

cjbj commented 1 year ago

Personally I suggest you hack our driver code in lib/oracledb.js where we throw the version check error and do either or both of:

PS Please use triple backquotes to mark your code blocks in GitHub issues.

labkapapka commented 1 year ago

I see your Cypress environment cant access node modules as it is . Your tests passed with previous versions like oracledb@5.5?

No, tests wasn't success when I use oracledb@5.5. I get the same Error, like this: "node-oracledb 5.x.x requires Node.js 8.x or later"

labkapapka commented 1 year ago

Give me, please, extended guide how to do this. Which code and where I need to write?

sharadraju commented 1 year ago

@labkapapka You might want to try what this user did to enable cypress to work with node-oracledb: https://github.com/oracle/node-oracledb/issues/1261#issuecomment-777880518

Based on the inputs from this issue, it seems cypress does not have a node version available in its spec files, so even trying to import/require oracledb causes immediate failure with the NJS-069 error

sharadraju commented 1 year ago

This is a duplicate of #1261. Hence closing this issue. Request the user to refer to issue #1261