node-oracledb icon indicating copy to clipboard operation
node-oracledb copied to clipboard

Precompiled node-oracle

Open bchr02 opened this issue 11 years ago • 211 comments

If you are having issues installing node-oracledb or if you don't have a build environment and are looking to install a pre-compiled version of node-oracledb then check out my new npm module oracledb-pb, which can be installed like so: npm install oracledb-pb

Then, within your app, instead of: var oracledb = require('oracledb'); use: var oracledb = require('oracledb-pb');

oracledb-pb is an unofficial oracledb module which I have published to npm for the benefit of allowing the community to get up and running with oracledb quickly. It's only dependency is the Microsoft Visual C++ Runtime. The module even downloads and installs the necessary Oracle Instant Client Packages for you and adds the folder to your PATH environment variable.

oracledb-pb is based on the work outlined below and you could optionally follow the below instructions instead which outlines how to install oracledb directly from my fork instead. For small projects I recommend oracledb-pb but for anything large scale or something that you will be publishing to npm I don't recommend it. The main reason is because it is not officially supported by Oracle and another reason is because I can't make any guarantees as to how frequently or how long term I can maintain it.

Fork with a working setup here.

Install instructions:

The following instructions allows one to install oracledb (from my fork) without needing a build environment.

Requirements: One must have an environment for which a binary has been built for. The table below under the section "List of available binaries" contains the binaries that I have compiled thus far. The list is limited because an automated build system is not yet utilized and I am manually needing to create these for each environment.

  1. Open command prompt and navigate to the folder where you would like to install oracledb.
  2. Paste the following command: npm install https://github.com/bchr02/node-oracledb#prebuild_support --toolset=oci12.1-msvs2015
  3. Before pressing enter, at the --toolset option, change the oci version and msvs version so they match your environment. For example, --toolset=oci12.1-msvs2015 means you have the 12.1 version of the Oracle Client library and 2015 version of Visual Studio's C++ Redistributable. UPDATE: actually I made a mistake. With OCI 12.1 it's the 2010 Redistribuatable that is needed not the 2015. I will be correcting this but in the meantime you will need to use ...msvs2015 option when installing while making sure you have the 2010 Redistributable installed. Sorry for the confusion.
  4. Press Enter to run the command and once finished, if you scroll up, you should see the words "is installed via remote".
  5. Once installed you must make sure the correct Oracle libraries are available in PATH. The version must match a version listed in the above table. Currently only 12.1 have prebuilts***

List of available binaries as of Jan 9th 2017

oracledb Version Platform Arch Node ABI Version OCI version MS VS C++ Redist. Version Install Command
1.12.2 Linux 64bit 51 (Node v7) 12.1 n/a npm install https://github.com/bchr02/node-oracledb#prebuild_support --toolset=oci12.1
1.12.2 Linux 64bit 48 (Node v6) 12.1 n/a npm install https://github.com/bchr02/node-oracledb#prebuild_support --toolset=oci12.1
1.12.2 Windows 64bit 51 (Node v7) 12.1 2015 npm install https://github.com/bchr02/node-oracledb#prebuild_support --toolset=oci12.1-msvs2015
1.12.2 Windows 64bit 48 (Node v6) 12.1 2015 npm install https://github.com/bchr02/node-oracledb#prebuild_support --toolset=oci12.1-msvs2015
1.11 Windows 64bit 48 (Node v6) 12.1 2015 npm install https://github.com/bchr02/node-oracledb#prebuild_support --toolset=oci12.1-msvs2015
1.11 Windows 64bit 46 (Node v4) 12.1 2015 npm install https://github.com/bchr02/node-oracledb#prebuild_support --toolset=oci12.1-msvs2015
1.11 Windows 64bit 14 (Node v0.12) 12.1 2015 npm install https://github.com/bchr02/node-oracledb#prebuild_support --toolset=oci12.1-msvs2015
1.10.1 Windows 64bit 48 (Node v6) 12.1 2015 npm install https://github.com/bchr02/node-oracledb#prebuild_support --toolset=oci12.1-msvs2015
1.10.1 Windows 32bit 48 (Node v6) 12.1 2015 npm install https://github.com/bchr02/node-oracledb#prebuild_support --toolset=oci12.1-msvs2015
1.10.1 Windows 64bit 46 (Node v4) 12.1 2015 npm install https://github.com/bchr02/node-oracledb#prebuild_support --toolset=oci12.1-msvs2015
1.10.1 Windows 32bit 46 (Node v4) 12.1 2015 npm install https://github.com/bchr02/node-oracledb#prebuild_support --toolset=oci12.1-msvs2015
1.10.1 Windows 32bit 14 (Node v0.12) 12.1 2015 npm install https://github.com/bchr02/node-oracledb#prebuild_support --toolset=oci12.1-msvs2015
1.10.1 Windows 32bit 14 (Node v0.12) 12.1 2012 npm install https://github.com/bchr02/node-oracledb#prebuild_support --toolset=oci12.1-msvs2012

Instructions to build and package can be found here: https://github.com/oracle/node-oracledb/pull/392

bchr02 avatar Feb 09 '15 20:02 bchr02

+1

Bigous avatar Feb 09 '15 23:02 Bigous

that would be inconsistent with any other node module i saw which has c code in it. It would actually break the concept of npm install/update.

agree its a pain to set everything up in windows, but its a one time thing and you have all tools provided by Microsoft free.

The only issue is the 64bit support, meaning, to 64 bit compiler from microsoft is not free so you will have to use 32bit node.js exe to run those modules, otherwise you won't be able to load those 32bit compiled libs.

sagiegurari avatar Feb 10 '15 05:02 sagiegurari

Hi @sagiegurari,

That's true, when you talk about node module - but I have seen some modules which use phanton in the test cases and when it fails to compile, it downloads the precompiled phanton and works like a charm. Node itself is not in that way too, it's distributed precompiled.

But here we are talking about an Oracle Client. All oracle clients provided by oracle are distributed compiled. And this one is a wrapper to a compiled one (OCI). So, I cannot see a point in providing one client half compiled and half to be compiled.

It would be better if Oracle could compile it and distribute it together with the instant client itself or in a separated ZIP file which could be downloaded by npm install, just like it does with ODP.NET.

Bigous avatar Feb 10 '15 11:02 Bigous

@sagiegurari regarding 64 bit, is this usable?: http://www.visualstudio.com/products/visual-studio-community-vs (Can you tell I rarely use Windows?)

cjbj avatar Feb 10 '15 21:02 cjbj

After doing some research, there appears to be a lot of node community support for pre-compiled modules: see https://github.com/npm/npm/issues/1891 and https://github.com/joyent/node/issues/4398

Based on what I'm reading, it seems there are at least two possible solutions:

  1. use node-pre-gyp - some minor gochas:
    • On Windows you'll need to make sure your users have the right C++ runtime installed.
    • On OS X you'll need to make sure you compile your module with the desired value passed to the -mmacosx-version-min flag.
    • On Linux you'll need to make sure to create your binaries on the oldest system you want to support. This means practically that if you create your binaries on Ubuntu Precise they will work on Ubuntu Precise and any other linux distro more recent (like Debian Sid or Ubuntu Trusty).
  2. use module-foundry - I believe this would be something that Oracle would need to create on their end to use as part of their build process. This will allow them to build for Linux, SmartOS and Windows.

@cjbj What do you think? Can we implement any one of these two options? node-pre-gyp appears to be the easiest to implement. What are your thoughts?

bchr02 avatar Feb 10 '15 23:02 bchr02

Great to see the enthusiasm. Keep the ideas and references coming.

To be realistic, we have a lot of base things to do first, before branching out to building binaries.

cjbj avatar Feb 11 '15 01:02 cjbj

Hi @cjbj seems I'm a bit outdated and the new express editions do support 64bit compilation. They have a X86_ x64 cross-compiler which means its a 32bit compiler that is able to generate 64 bit executables. so we should be ok here. I took the info from: https://msdn.microsoft.com/en-us/library/hs24szh9.aspx Issue is that it shows it needs windows 8.

as for the community edition, I see no where any statement on what is actually supports and I have never tried it.

sagiegurari avatar Feb 11 '15 04:02 sagiegurari

Module foundry looks good.

ghost avatar Jul 09 '15 16:07 ghost

@cjbj any update on this getting done before node-oracle is out of beta?

bchr02 avatar Jul 23 '15 03:07 bchr02

Not even on the radar, sorry. Priorities change dynamically, so once we have LOBs etc we will revisit it.

cjbj avatar Jul 23 '15 03:07 cjbj

@bchr02 on a related topic, do you have any fresh comments for the Windows installation section of INSTALL.md https://github.com/oracle/node-oracledb/blob/master/INSTALL.md#instwin

cjbj avatar Jul 24 '15 05:07 cjbj

@cjbj Sorry for taking so long to respond. I have been busy. Overall the updated Windows installation section is excellent. It has a lot of helpful information and, for the most part, contains all the information one would need for a successful installation. I think you have done a good job.

I do have a few comments though:

Under section 6.1 you write:

You will also need the matching Visual C++ Redistributable for Visual Studio.

It would be helpful to the reader if they knew that, at least with Visual Studios 2013, and I believe with older versions as well, that the Visual C++ Redistributable is automatically installed with it. However this is probably a moot point though because I realized that you could safely uninstall Visual C++ Redistributable, reboot your system to make sure it's fully uninstalled and you could still compile and use the oracedb module. Perhaps we should eliminate the comment of needing the redistributable altogether. I have tested and verified this to be true with a test system running Windows 7 x64 and Visual Studio 2013.

Under section 6.3 where you write:

Optionally rename the resulting directory to C:\oracle\instantclient

I like this naming convention but why not be consistent with the directories under section 6.4 where you write:

set OCI_LIB_DIR=C:\oracle\instantclient_12_1\sdk\lib\msvc set OCI_INC_DIR=C:\oracle\instantclient_12_1\sdk\include

I would rename these to:

set OCI_LIB_DIR=C:\oracle\instantclient\sdk\lib\msvc set OCI_INC_DIR=C:\oracle\instantclient\sdk\include

Under section 6.4

The first paragraph discusses the need to use a Visual Studio command prompt or running certain batch files. I never had to do either of those things. Maybe it would be good to add a comment as to when this would be needed. I have installed oracledb on many different type of windows systems with various versions of Visual Studios and have never needed to do this. So if I were seeing this trying to do an install for the first time, it would slow me down. When I install the oracledb, I have had success by either opening a regular command prompt via Start, Run, cmd or by opening the node.js command prompt via Start, All Programs, Node.js, Node.js command prompt.

bchr02 avatar Jul 29 '15 20:07 bchr02

@cjbj By the way, I noticed that there have been some requests for a video demonstrating the installation of oracledb on Windows, so I created one. Please check it out and let me know what you think: Video - install of oracledb on Windows 7 x64

bchr02 avatar Jul 29 '15 20:07 bchr02

@bchr02 great job on the video, which I'm watching at the moment. I'll address your earlier comments too in a while. The install guide has already greatly improved with your input and this should make it better. (In the video at about the 4 minute mark you mentioned the OCCI interface. node-oracledb uses OCI not OCCI).

cjbj avatar Jul 29 '15 21:07 cjbj

One good reason to distribute binaries of some form is gyp's dependency on Python 2.7, which will become more and more a liability in future as platforms start to ship Python 3 by default.

Reference: https://github.com/TooTallNate/node-gyp/issues/193

cjbj avatar Jul 29 '15 21:07 cjbj

@cjbj

(In the video at about the 4 minute mark you mentioned the OCCI interface. node-oracledb uses OCI not OCCI).

Oops, good catch! I will splice the video to fix this. :-) No worries. Let me know if there is anything else you find.

bchr02 avatar Jul 29 '15 22:07 bchr02

@cjbj Okay, so I corrected the video, but I was not able to keep the same link address. Therefore, the video is now located here. I will also update the link in my original video post. Thanks.

bchr02 avatar Jul 30 '15 13:07 bchr02

@cjbj If the community were to create a pull request that utilized node-pre-gyp to conditionally use pre-built binaries based on processor architecture and platform (and would fall back on compiling), would you accept it?

bchr02 avatar Jul 30 '15 15:07 bchr02

@bchr02 @Bigous I'd love to see the plan or a prototype PR - you have both signed the OCA so no issues on that side, even if other parts of the process take some time. Using node-pre-gyp seems a logical step forward.

cjbj avatar Jul 31 '15 01:07 cjbj

@cjbj Okay, in that case we will start working on something.

@Bigous how to you want to proceed? I know from your pull requests that you have more experience than me with node-gyp. Therefore, do you prefer to take the lead on this and we can use your own fork? If not, for whatever reason, maybe you have a busy schedule, I could take the lead and we could use my fork here: bchr02/node-oracledb.

I do not have a lot of experience with node-gyp let alone node-pre-gyp, so I may not be the best person to take the lead. Nevertheless, I don't think I would have a problem figuring things out.

Lastly, if there is anyone else in the community who has experience with node-pre-gyp and is interested to help, please let us know. Thanks.

bchr02 avatar Jul 31 '15 15:07 bchr02