简体   繁体   中英

Not able to connect to Oracle using NodeJS

I am trying to run a NodeJS(v0.10.36) file which contains connection to Oracle database.

When I try to run the project, I get the below error.

M1318657:testOracle yogeshJC$ node app.js

module.js:340
throw err;
^
Error: Cannot find module '../build/Release/oracle_bindings'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/yogeshJC/testOracle/node_modules/oracle/lib/oracle.js:2:16)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)

app.js contains simple script to connect to Oracle Database.

I have followed the instructions here to install oracledb

Oracle Version : 11.2

Following environments have been set :

OCI_HOME
OCI_INC_DIR
OCI_VERSION
OCI_LIB_DIR

Any leads to resolve the issue would be appreciated.

Edit :

sudo npm install oracledb

M1318657:testOracle yogeshJC$ sudo npm install oracledb
Password:
npm WARN package.json appdynamics@4.1.10 No repository field.
npm WARN package.json express-namespace@0.1.1 No repository field.
|
> oracledb@1.9.3 install /Users/yogeshJC/testOracle/node_modules/oracledb
> node-gyp rebuild

  CXX(target) Release/obj.target/oracledb/src/njs/src/njsOracle.o
  CXX(target) Release/obj.target/oracledb/src/njs/src/njsPool.o
  CXX(target) Release/obj.target/oracledb/src/njs/src/njsConnection.o
  CXX(target) Release/obj.target/oracledb/src/njs/src/njsResultSet.o
  CXX(target) Release/obj.target/oracledb/src/njs/src/njsMessages.o
  CXX(target) Release/obj.target/oracledb/src/njs/src/njsIntLob.o
../src/njs/src/njsIntLob.cpp:1222:3: warning: cannot refer to a non-static member from the handler of a constructor function try block [-Wexceptions]
  cleanup();
  ^
1 warning generated.
  CXX(target) Release/obj.target/oracledb/src/dpi/src/dpiEnv.o
  CXX(target) Release/obj.target/oracledb/src/dpi/src/dpiEnvImpl.o
../src/dpi/src/dpiEnvImpl.cpp:114:3: warning: cannot refer to a non-static member from the handler of a constructor function try block [-Wexceptions]
  cleanup();
  ^
1 warning generated.
  CXX(target) Release/obj.target/oracledb/src/dpi/src/dpiException.o
  CXX(target) Release/obj.target/oracledb/src/dpi/src/dpiExceptionImpl.o
  CXX(target) Release/obj.target/oracledb/src/dpi/src/dpiConnImpl.o
../src/dpi/src/dpiConnImpl.cpp:100:3: warning: cannot refer to a non-static member from the handler of a constructor function try block [-Wexceptions]
  cleanup();
  ^
../src/dpi/src/dpiConnImpl.cpp:139:3: warning: cannot refer to a non-static member from the handler of a constructor function try block [-Wexceptions]
  cleanup ();
  ^
2 warnings generated.
  CXX(target) Release/obj.target/oracledb/src/dpi/src/dpiDateTimeArrayImpl.o
  CXX(target) Release/obj.target/oracledb/src/dpi/src/dpiPoolImpl.o
../src/dpi/src/dpiPoolImpl.cpp:145:3: warning: cannot refer to a non-static member from the handler of a constructor function try block [-Wexceptions]
  cleanup();
  ^
1 warning generated.
  CXX(target) Release/obj.target/oracledb/src/dpi/src/dpiStmtImpl.o
../src/dpi/src/dpiStmtImpl.cpp:121:3: warning: cannot refer to a non-static member from the handler of a constructor function try block [-Wexceptions]
  cleanup ();
  ^
1 warning generated.
  CXX(target) Release/obj.target/oracledb/src/dpi/src/dpiUtils.o
  CXX(target) Release/obj.target/oracledb/src/dpi/src/dpiLob.o
  CXX(target) Release/obj.target/oracledb/src/dpi/src/dpiCommon.o
  SOLINK_MODULE(target) Release/oracledb.node
  SOLINK_MODULE(target) Release/oracledb.node: Finished
oracledb@1.9.3 node_modules/oracledb
└── nan@2.3.4

You have some conflicts. The error you pasted refers to node_modules/oracle which is the older, unsupported module for Oracle DB and is not the oracledb module you show being installed.

Recommendations:

  • remove the obsolete oracle module
  • consistently use the newer, better oracledb module.
  • check the install instructions : node-oracledb doesn't use OCI_VERSION or OCI_HOME
  • try an example that uses oracledb
  • optionally use the new 12.1 Instant Client for OS X
  • upgrade Node to a secure patch level. And preferably use recent release like 4 LTS or 6.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM