Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AngularJS & NodeJS & OracleDB Implementation Has Problem With The Library #957

Closed
tbyoran opened this issue Aug 3, 2018 · 4 comments
Closed
Labels

Comments

@tbyoran
Copy link

tbyoran commented Aug 3, 2018

For general questions:

I'm working on a project which uses AngularJS as fronted and NodeJS as backend. When I implement the .js folder that connects my oracle database server, the compiler gives me the error below.

Also the script works by itself via this command node app.js

How can I fix that?

Answer the following questions:

  1. What is your Node.js version? Is it 64-bit or 32-bit?

64-bit & v8.11.8

  1. What is your node-oracledb version?

v2.3.0

  1. What is your Oracle client (e.g. Instant Client) version? Is it 64-bit or 32-bit? How was it installed? Where is it installed?

64-bit & v12.2

  1. What is your Oracle Database version?

Up to date

  1. What is your OS and version?

Windows 10@Latest

  1. What is your compiler version?
  1. What Oracle environment variables did you set? How exactly did you set them?
  1. What is the PATH environment variable (on Windows) or LD_LIBRARY_PATH (on Linux) set to? On macOS, what is in ~/lib?

All have been set up as in the installation files.

  1. What exact command caused the problem (e.g. what command did you try to install with)? Who were you logged in as?

const oracledb = require ('oracledb');

  1. What error(s) you are seeing?

WARNING in ./node_modules/oracledb/lib/oracledb.js
42:18-44 Critical dependency: the request of a dependency is an expression

WARNING in ./node_modules/oracledb/lib/oracledb.js
48:21-45 Critical dependency: the request of a dependency is an expression

ERROR in ./node_modules/oracledb/lib/oracledb.js
Module not found: Error: Can't resolve 'path' in 'C:\Users\tbyor\Desktop\angularProject\Base\node_modules\oracledb\lib'
ERROR in ./node_modules/oracledb/lib/lob.js
Module not found: Error: Can't resolve 'stream' in 'C:\Users\tbyor\Desktop\angularProject\Base\node_modules\oracledb\lib'
ERROR in ./node_modules/oracledb/lib/querystream.js
Module not found: Error: Can't resolve 'stream' in 'C:\Users\tbyor\Desktop\angularProject\Base\node_modules\oracledb\lib'

@danilohgds
Copy link

danilohgds commented Aug 3, 2018

Angular code and oracledb don't go well together. (Angular executes client side...oracledb...doesn't)
By the looks of it you have it all bundled in a single project.
Consider using a rest-api project to provide you the data you need.
Here's a good place to start : https://jsao.io/2018/03/creating-a-rest-api-database-basics/

@tbyoran
Copy link
Author

tbyoran commented Aug 3, 2018

I use the same implementation for oracledb.

const oracledb = require ('oracledb'); This part gives me the error

const oracledb = require ('oracledb');
const config = require ('./dbconfig');

//...
constructor () {
    //console.log ("oracledb: " + oracledb);
    oracledb.getConnection (
      // Database Connection
      {
        user: config.user,
        password: config.password,
        connectString: config.connectString
      },
      function (err, connection) {
        if (err) {
          console.error ("Error #01: " + err.message);
          return;
        }
        this.conn = connection;
        console.log ("Connection is successful!");
      }
    );
}
//...

@danilohgds
Copy link

@tbyoran

Allow me to explain in a better manner. The problem is not your code, but how your project is built.

Angular is only meant for FrontEnd Development, you cannot have oracleDB inside an Angular project, it will not work properly. The angular code executes itself in the user's browser, which is completely different in nature to how OracleDB works. OracleDB compiles itself into a host machine, with proper adjustments made to behave correctly given different system/architecture etc. Thus, using OracleDB in a FrontEnd project is not a proper approach.

Your code for OracleDB functionality is correct, however, you need to separate it into a project of its own.

The correct way to design an application to access OracleDB is to have a backend only project that will access your data, and share that through Rest Apis. In your code screenshots, it is possible to see that the code is inside the Angular project, which is not the correct way to go. Start a new NPM project with only OracleDB and the dependencies needed to share data (express, koa, nest.js, pick your favorite). It will work for sure.

There are some other issues in this repo that have addressed the same question: #894

I hope this clarifies your doubts.

@cjbj cjbj added the question label Aug 3, 2018
@cjbj
Copy link
Member

cjbj commented Sep 4, 2018

Closing due to lack of activity. Thanks @danilohgds for your inputs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants