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

help with 'pkg' moving node app to RHEL7 #1098

Closed
cyrfer opened this issue May 17, 2019 · 9 comments
Closed

help with 'pkg' moving node app to RHEL7 #1098

cyrfer opened this issue May 17, 2019 · 9 comments
Labels

Comments

@cyrfer
Copy link

cyrfer commented May 17, 2019

For general questions:

Describe exactly what you did and what you want to happen.

  • I want to know how to move my code around on a machine without getting an error that the oracledb runtime could not be found.
  • I probably just need to know what are the system dependencies that are used by the oracledb package so I can export LD_LIBRARY_PATH=/something
  • I wrote a CLI using node code that imports oracledb module. I converted my node script into an executable with NPM's pkg . command.
  • I want to execute this on a remote machine. I emulate the remote machine using a local Docker container. If I move the packaged executable to another folder on my machine, I get an error about the runtime is not found. Knowing how to move the executable on my local container will help me know the dependencies for the remote machine. I can install dependencies with 'yum' on the local container if that helps the mobility of my executable.
  • The remote machine presents additional challenges in that it does not have internet access and only a subset of yum packages are available on an internal repo. The remote machine does NOT have 'nodejs' and 'npm' yum packages due to the subset of yum available, BUT this is overcome by converting the node script into an executable via the pkg . command in my local container.

For installation issues:

Answer the following questions:

  1. What is your Node.js version: use console.log(process.version)? Is it 64-bit or 32-bit: use console.log(process.arch)?
  • 8.16.0, but I'm flexible
  • x64
  1. What is your node-oracledb version: use console.log(oracledb.versionString)?
  • 3.1.2, but i'm flexible
  1. What exact command caused the problem (e.g. what command did you try to install with)? Who were you logged in as?
  • attempting to package as a self-contained app via 'pkg .'
  • (as root) running my program after moving to another directory from the original project folder (containing package.json) causes the problem. I run it like this:
    /tmp/nuxeo-data-etl-linux
  • (as user, same error) I also see the problem when I move it from a local CentOS container to a RHEL7 machine
  1. What error(s) you are seeing?
$ ./nuxeo-data-etl-linux 
pkg/prelude/bootstrap.js:1185
      throw error;
      ^

Error: NJS-045: cannot load a node-oracledb binary for Node.js 8.16.0 (linux x64) 
  Looked for /snapshot/app/node_modules/oracledb/build/Release/oracledb-abi57-linux-x64.node, /snapshot/app/node_modules/oracledb/build/Release/oracledb.node, /snapshot/app/node_modules/oracledb/build/Debug/oracledb.node
  Node-oracledb installation instructions: https://oracle.github.io/node-oracledb/INSTALL.html

    at Object.<anonymous> (/snapshot/app/node_modules/oracledb/lib/oracledb.js:55:13)
    at Module._compile (pkg/prelude/bootstrap.js:1261:22)
    at Object.Module._extensions..js (module.js:662:10)
    at Module.load (module.js:564:32)
    at tryModuleLoad (module.js:504:12)
    at Function.Module._load (module.js:496:3)
    at Module.require (module.js:595:17)
    at Module.require (pkg/prelude/bootstrap.js:1166:31)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/snapshot/app/node_modules/oracledb/index.js:1:80)
    at Module._compile (pkg/prelude/bootstrap.js:1261:22)
    at Object.Module._extensions..js (module.js:662:10)
    at Module.load (module.js:564:32)
    at tryModuleLoad (module.js:504:12)
    at Function.Module._load (module.js:496:3)
    at Module.require (module.js:595:17)
  1. What OS (and version) is Node.js executing on: use console.log(process.platform)?
  • linux
  1. What is your Oracle client (e.g. Instant Client) version: use console.log(oracledb.oracleClientVersionString)? Is it 64-bit or 32-bit? How was it installed? Where is it installed?
  • installed via npm i -S oracledb
> console.log(oracledb.oracleClientVersionString)
Error: DPI-1047: Cannot locate a 64-bit Oracle Client library: "libclntsh.so: cannot open shared object file: No such file or directory". See https://oracle.github.io/odpi/doc/installation.html#linux for help
  1. What is your Oracle Database version: use console.log(connection.oracleServerVersionString)?
  • TBD
  1. What is the PATH environment variable (on Windows) or LD_LIBRARY_PATH (on Linux) set to? On macOS, what is in ~/lib?
  • I have no problems on my local CentOS environment before moving outside of project folder, but I do see a problem with I move the packaged executable outside of the project folder, and the system result is (nil),
# echo $LD_LIBRARY_PATH

  • on the remote RHEL7 environment, the result is also (nil),
$ echo $LD_LIBRARY_PATH

  1. What Oracle environment variables did you set? How exactly did you set them?
  • None.
  1. Do you have a small, single Node.js script that immediately runs to show us the problem?
  • Not yet, but I can make one..
@cjbj cjbj added the question label May 18, 2019
@cjbj cjbj changed the title help moving node app to RHEL7 help with 'pkg' moving node app to RHEL7 May 18, 2019
@cjbj
Copy link
Member

cjbj commented May 18, 2019

Which error do you have? The one in your point 4 or 6?

I haven't had time to use 'pkg'. Make sure you have the same Node version on the machine you create the package as you intend to deploy on. (node-oracledb v4 will be more portable in regard to Node.js versions)

@cjbj
Copy link
Member

cjbj commented May 18, 2019

From https://github.com/zeit/pkg

Native addons (.node files) use is supported, but packaging .node files inside the executable is not resolved yet. You have to deploy native addons used by your project to the same directory as the executable.

I just tried pkg and put the created binary in a directory which also had a node_modules/oracledb hierarchy and the app ran OK. When I deleted node_modules then the app failed with NJS-045. I'll let you experiment more.

@cyrfer
Copy link
Author

cyrfer commented May 18, 2019

4 is my error. 6 came from answering the interview questions. I think 6 is at the heart of the matter. I'm new to your model so I do not know what package adds the dependencies that you pointed out. I'll try push my local build over to the remote machine, but it would be nice to install a RPM.

@cjbj
Copy link
Member

cjbj commented May 18, 2019

You won't be getting both of those errors at a time. So if 4 is your error, then you need to "fix" that.

https://github.com/oracle/node-oracledb/blob/master/index.js loads https://github.com/oracle/node-oracledb/blob/master/lib/oracledb.js which loads one of the build/Release/*.node binaries. The specific binaries that were being looked for are shown in the NJS-045 message.

You'll need a *.node binary, and some Oracle client libraries. For the latter on RH, I recommend the RPMs from http://yum.oracle.com/repo/OracleLinux/OL7/oracle/instantclient/x86_64/index.html

@cyrfer
Copy link
Author

cyrfer commented May 18, 2019

I ran yum install -y oracle-instantclient19.3-basic-19.3.0.0.0-1.x86_64.rpm.

Do you know where the files are installed? I'm hoping the Oracle client libraries are in a standard lib path, but my program still cannot find them.

UPDATE
I found the files

# find /usr/ -iname libclntsh.so
/usr/lib/oracle/19.3/client64/lib/libclntsh.so
# export LD_LIBRARY_PATH=/usr/lib/oracle/19.3/client64/lib/

executing my MOVED app, like below, still results in the error in point 4 above.
cd /tmp && ./nuxeo-data-etl-linux

To clarify, I only get the error in point 6 above when executing code in my source code folder which contains package.json and node_modules. I used the Node REPL to do the interview questions from my source code folder.

@cjbj
Copy link
Member

cjbj commented May 18, 2019

(i) The Instant Client RPM installation instructions show that you no longer need to set the library path when you use 19.3 Instant Client, so don't set LD_LIBRARY_PATH (unless you ever end up using an older version of Instant Client. And even then, use ldconfig instead).

(ii) finding Instant Client isn't your distribution problem, as far as I can see. What you have is some limitation of pkg. If I read the pkg instructions correctly and they are up to date, and you can't find a way to make it bundle & use node-oracledb's build/Release/*.node libraries then you will need to install node-oracledb separately on each target computer.

(iii) One other thing to throw in the mix is using RPMs for Node.js and node-oracledb. See http://yum.oracle.com/oracle-linux-nodejs.html Note these currently use 18c Instant Client or older, so you will have to use ldconfig, as shown. That way, you could distribute your package, set NODE_PATH (as shown), and (probably) run your app.

@cyrfer
Copy link
Author

cyrfer commented May 19, 2019

Thanks!

So I tested in my local container, copying the files listed here to another spot (/tmp) in my local container,

# find node_modules/oracledb/build/Release/ -iname *linux*.node
node_modules/oracledb/build/Release/oracledb-abi64-linux-x64.node
node_modules/oracledb/build/Release/oracledb-abi48-linux-x64.node
node_modules/oracledb/build/Release/oracledb-abi67-linux-x64.node
node_modules/oracledb/build/Release/oracledb-abi57-linux-x64.node

After experimenting, it turns out only oracledb-abi57-linux-x64.node needed to be copied to the directory where the packaged application exists. It also worked when I copied it to a remote machine.

I'll let you know if I have any more problems. I think this issue is done!

@cyrfer cyrfer closed this as completed May 19, 2019
@cjbj
Copy link
Member

cjbj commented May 20, 2019

@cyrfer thanks for the useful info. Have you thought about contacting the pkg team to see if they will support *.node files and/or compiling the module binary directly into the package?

ABI 57 corresponds to Node.js 8's ABI. With the future node-oracledb 4, the refactor to use N-API will mean one *.node binary will work with Node.js 8 onwards.

@TenaciousTechnologistExtraordinaire
Copy link

TenaciousTechnologistExtraordinaire commented Oct 20, 2021

From https://github.com/zeit/pkg

Native addons (.node files) use is supported, but packaging .node files inside the executable is not resolved yet. You have to deploy native addons used by your project to the same directory as the executable.

I just tried pkg and put the created binary in a directory which also had a node_modules/oracledb hierarchy and the app ran OK. When I deleted node_modules then the app failed with NJS-045. I'll let you experiment more.

Hello. I have followed your instructions for compiling node-oracledb from source using the following command:
npm install https://github.com/oracle/node-oracledb/releases/download/v5.2.0/oracledb-src-5.2.0.tgz
I can run the following command successfully and the application writes to the database: node App.js
...but when I run the command to package into exe: pkg -t node10-win "App.js" --build
...I get the following error when trying to run the packaged exe:
Error: NJS-045: cannot load a node-oracledb binary for Node.js 10.24.1 (win32 x64)
I have tried copying the binary files (including oracledb.node) from:
".../[PATH TO PROJECT]/node_modules\oracledb\build\Release" into the same folder as the packaged exe, and also into subfolder structure /node_modules/oracledb . no matter where I put the oracledb binary, the packaged exe does not see it. Do you have any suggestions? Thanks for reading :)

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