Node.JS and DB2 Connection - node.js

I am attempting to begin writing a Node.JS Application that relies on some data stored in a DB2 database. I've come across two node modules that would work for me. DB2.js and ibm_db, both on the NPMjs site.
After following the install guides for both
https://github.com/herzi/db2.js
and
https://www.ibm.com/developerworks/community/blogs/pd/entry/using_ibm_db2_from_node_js4?lang=en
After following IBM's install guide for their module, I realized that I need to get the Linux drivers for DB2 installed. However, their instructions aren't very clear and have me install a new copy of node into my home folder. I have nodejs already installed globally and when I substitute it's install folder at /usr/lib/nodejs I still get compile errors when trying to do node-gyp configure build in either my clone of db2.js or ibm_db
The specific error I'm getting is related to some files that are supposed to get installed with the Linux DB2 drivers, namely sqlcli.h and sqlcli1.h. Here is the error message I get when running node-gyp configure build for either project.
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory `/home/mint/Programming/node-ibm_db/build'
CXX(target) Release/obj.target/odbc_bindings/src/odbc.o
In file included from ../src/odbc.cpp:25:0:
../src/odbc.h:29:21: fatal error: sqlcli1.h: No such file or directory
#include <sqlcli1.h>
^
compilation terminated.
make: *** [Release/obj.target/odbc_bindings/src/odbc.o] Error 1
make: Leaving directory `/home/mint/Programming/node-ibm_db/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Linux 3.11.0-12-generic
gyp ERR! command "node" "/usr/bin/node-gyp" "configure" "build"
gyp ERR! cwd /home/mint/Programming/node-ibm_db
gyp ERR! node -v v0.10.15
gyp ERR! node-gyp -v v0.13.0
gyp ERR! not ok

I think you need to install the IBM Data Server Client package for your version of the DB2 server -- it contains, in addition to the libraries, the header files required for compilation.

Just run "npm install ibm_db" and you'll get those include files under ibm_db/installer/clidriver/include folder. Thanks.

Related

Certificate error was raised when installing oracledb in Electron app

I am running Windows 7 with oracledb v1.10.0, electron-prebuilt v1.2.2, electron-rebuild v1.1.5, node v0.12.7, and npm v2.11.3. When I execute node_modules/.bin/electron-rebuild -f -w oracledb, I receive the following error:
gyp ERR! stack Error: certificate not trusted
gyp ERR! stack at Error (native)
gyp ERR! stack at TLSSocket.<anonymous> (_tls_wrap.js:929:36)
gyp ERR! stack at TLSSocket.emit (events.js:104:17)
gyp ERR! stack at TLSSocket._finishInit (_tls_wrap.js:460:8)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "H:\\electron-quick-start\\node_modules\\electron-rebuild\\node_modules\\npm\\node_modules\\node
-gyp\\bin\\node-gyp.js" "install" "--target=1.2.7" "--arch=x64" "--dist-url=https://gh-contractor-zcbenz.s3.amazonaws.co
m/atom-shell/dist"
gyp ERR! cwd H:\electron-quick-start
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
How can I get this command to successfully execute?
It seems to be Module did not self register. On Windows, 'node' is actually a batch file that calls iojs and native modules don't like that. You will need to copy your iojs executable to 'node' as well to satisfy native modules.
Now, I am unclear about exactly what your attempting. But if you would like to utilize a native module from within Electron, you will need to build your native code against the Electron includes/header, not those of iojs. You can take a look at this for an example of the command syntax:
node-gyp rebuild --target=0.22.3 --arch=ia32 --target_platform=win --dist-url=https://atom.io/download/atom-shell
The certificate error I was getting was due to being behind a corporate firewall under Windows. To solve that, I removed the s from https so the dist-url value became http://gh-contractor-zcbenz.s3.amazonaws.com/atom-shell/dist. The other error I was getting was (as mentioned by #Thennarasan) "Module did not self-register" and to solve that I called the following commands and it worked:
PS H:\electron-app> cd node_modules\oracledb
PS H:\electron-app\node_modules\oracledb> node-gyp rebuild --target=1.2.8 --arch=x64 --target_platform=win --dist-url=http://gh-contractor-zcbenz.s3.amazonaws.com/atom-shell/dist --msvs_version=2013
PS H:\electron-app> cd ..\..
I got help from this Github issue https://github.com/electron/electron/issues/1529.

Receiving Fatal Error c1083, Cannot open include file stddef.h while building node-gyp in Aurelia Project

I am been facing this problem for weeks now, with no hope of being solved. I am new to Aurelia JavaScript Framework and I am getting grips around the skeleton project hosted on github.
I have successfully installed nodejs, npm and jspm. As part of the requirements I am supposed to run:
npm install
The code runs well but hits a block with the error below
C:\Users\baba\.node-gyp\4.4.5\include\node\v8.h(18): fatal error C1083: Cannot open include file: 'stddef.h': No such file or directory [E:\fwb\node_modules\u
tf-8-validate\build\validation.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Users\baba\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 10.0.10586
gyp ERR! command "C:\\nodejs\\node.exe" "C:\\Users\\baba\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd E:\fwb\node_modules\utf-8-validate
gyp ERR! node -v v4.4.5
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
I don't know what I am missing or doing wrong. I would appreciate any help out there to get this running without any error or to put me in a step into the right direction to solve this.
Thank you.
This usually happens because you do not have the necessary build tools on your computer to build the package.
On Unix make sure you have:
python (v2.7 recommended, v3.x.x is not supported)
make
A proper C/C++ compiler toolchain, like GCC
On Mac OS X:
Xcode
You also need to install the Command Line Tools via Xcode. You can find this under the menu Xcode -> Preferences -> Downloads
This step will install gcc and the related toolchain containing make
On Windows:
Visual C++ Build Environment:
Option 1: Install Visual C++ Build Tools using the Default Install option.
Option 2: Install Visual Studio 2015 (or modify an existing installation) and select Common Tools for Visual C++ during setup. This also works with the free Community and Express for Desktop editions.

Getting started with Hubot

I just pulled hubot down from github. I ran npm install from \d\projects\hubot and got pounded with errors. The first error may be causing the rest:
d:\projects\hubot\node_modules\hubot-hipchat\node_modules\node-xmpp\node_modules\node-xmpp-core\node_modules\node-stringprep>node
"d:\Program Files\nodejs\node_modules\npm\bin\node-gyp-> bin\....\node_modules\node-gyp\bin\node-gyp.js"
rebuild gyp ERR! configure error gyp ERR! stack Error: Command failed:
gyp ERR! stack at ChildProcess.exithandler
(child_process.js:647:15) gyp ERR! stack at ChildProcess.emit
(events.js:98:17) gyp ERR! stack at maybeClose
(child_process.js:755:16) gyp ERR! stack at Socket.
(child_process.js:968:11) gyp ERR! stack at Socket.emit
(events.js:95:17) gyp ERR! stack at Pipe.close (net.js:465:12) gyp
ERR! System Windows_NT 6.1.7601 gyp ERR! command "node" "d:\Program
Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js"
"rebuild" gyp ERR! cwd
d:\projects\hubot\node_modules\hubot-hipchat\node_modules\node-xmpp\node_modules\node-xmpp-core\node_modules\node-stringprep
gyp ERR! node -v v0.10.29 gyp ERR! node-gyp -v v0.13.1 gyp ERR! not ok
The first line is pointing to a folder that does not exist on my machine:
d:\projects\hubot\node_modules\hubot-hipchat\node_modules\node-xmpp\node_modules\node-xmpp-core
node-xmpp-core does not exist. I tried installing node-xmpp-client and node-xmpp-sever and once again...tons of errors.
Any idea how I can get to the bottom of this mess?
Turns out I started with the wrong command.
Mac Setup
After pulling down the repo, the right command to start with is:
sudo npm install -g yo generator-hubot
Other stuff you need:
node.js
npm
Coffeescript : sudo npm install -g coffee-script
Redis
This is where things get tricky.
mkdir myhubot
cd myhubot
yo hubot --owner="Bot Wrangler " --name="Hubot" --description="Delightfully aware robutt" --adapter=campfire --defaults
(yo hubot command installs hubot!)
Now switch back to the root directory \wherever\hubot
npm install (install all the other bits hubot also needs)
switch back to the created directory \wherever\hubot\myhubot
Execute hubot :- bin/hubot (installs npm dependencies, loads scripts, launches hubot)
This will put you at a prompt and there will be a bunch of garbage on the screen. Hit <enter>. Now you get the correct prompt...
Hubot> and you can type "hubot help" to test him out.
If hubot does not respond to commands check to make sure you ran bin/hubot from the directory you created \wherever\hubot\myhubot. You can run bin/hubot from the root, but the prompt won't respond to commands.
Full instructions for setup were found on github.
Windows Setup
Basically the same thing. Don't use sudo before any of the commands listed above. You also need two additional packages before Hubot will run. I recommend installing these first:
Install Python 3.2: https://www.python.org/download/releases/3.2/
Install LMXL : https://pypi.python.org/pypi/lxml/3.4.2 (the one related to Python 3.2)
Write some scripts to make him do interesting things.
\wherever\hubot\myhubot\scripts\example.coffee is a good place to start

NPM install error - node-gyp

Trying to install xml-stream package but it keeps failing building dependencies. It seems to require vc2010(vcbuild.exe) but i installed the .Net Framework 2.0 SDK which has the vcbuild file and I'm getting the following error while installing xml-stream:
> node-expat#2.0.0 install G:\Pessoal\node\bugzilla\node_modules\xml-stream\node
_modules\node-expat
> node-gyp rebuild
G:\Pessoal\node\bugzilla\node_modules\xml-stream\node_modules\node-expat>node "D
:\Bin\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\
node-gyp.js" rebuild
Building the projects in this solution one at a time. To enable parallel build,
please add the "/m" switch.
The following error has occurred during XML parsing:
File: G:\Pessoal\node\bugzilla\node_modules\xml-stream\node_modules\node-expa
t\build\deps\libexpat\expat.vcproj
Line: 1
Column: 4916
VCBUILD : error Message: [G:\Pessoal\node\bugzilla\node_modules\xml-stream\nod
e_modules\node-expat\build\binding.sln]
Erro de sistema: -2147154687.
The file 'G:\Pessoal\node\bugzilla\node_modules\xml-stream\node_modules\node-
expat\build\deps\libexpat\expat.vcproj' has failed to load.
gyp ERR! build error
gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (D:\Bin\nodejs\node_modules\npm\node_m
odules\node-gyp\lib\build.js:267:23)
gyp ERR! stack at ChildProcess.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:810:
12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "D:\\Bin\\nodejs\\node_modules\\npm\\node_modules\\node-
gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd G:\Pessoal\node\bugzilla\node_modules\xml-stream\node_modules\node-
expat
gyp ERR! node -v v0.10.30
gyp ERR! node-gyp -v v0.13.1
gyp ERR! not ok
I believe this is happening because xml-stream depends on node-expat which depends on node-gyp which on windows will require you to either install VS2007 or in some other way install the correct SDK required by node-gyp.
In my case I did not wish to jump through those hoops and found it easier to simply use sax to write a very simple XML parser with no dependency on node-gyp.
I placed it on NPM: https://www.npmjs.com/package/no-gyp-xml-stream
Or just run: npm install no-gyp-xml-stream
It's still a work in progress but it works it's easy to use and it will allow you to read large XML files over a stream returning child elements via a call back. And it's only dependency is sax which will not require you to install anything.

installing node-oracle on Red Hat Enterprise Linux Server release 6.4 Santiago

I have been trying to install node-oracle on (Red Hat Enterprise Linux Server release 6.4 (Santiago) ) server .However, I was not successful.
I have followed the instructions on the webpage carefully, but when I run "npm install oracle", I get the following error.
I will paste the whole outcome of the execution of "npm install oracle" below.
npm http GET https://registry.npmjs.org/oracle
npm http 304 https://registry.npmjs.org/oracle
oracle#0.3.4 install /home/oracle/node_modules/oracle
node-gyp rebuild
make: Entering directory /home/oracle/node_modules/oracle/build'
CXX(target) Release/obj.target/oracle_bindings/src/connection.o
CXX(target) Release/obj.target/oracle_bindings/src/oracle_bindings.o
CXX(target) Release/obj.target/oracle_bindings/src/executeBaton.o
CXX(target) Release/obj.target/oracle_bindings/src/outParam.o
SOLINK_MODULE(target) Release/obj.target/oracle_bindings.node
/usr/bin/ld: cannot find -locci
collect2: ld returned 1 exit status
make: *** [Release/obj.target/oracle_bindings.node] Error 1
make: Leaving directory/home/oracle/node_modules/oracle/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess.handle.onexit (childprocess.js:789:12)
gyp ERR! System Linux 2.6.32-358.el6.x86_64
gyp ERR! command "node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/oracle/node_modules/oracle
gyp ERR! node -v v0.10.18
gyp ERR! node-gyp -v v0.10.6
gyp ERR! not ok
npm ERR! weird error 1
npm ERR! not ok code 0
I will be grateful if anyone can help in this.
I have tried several ways such as downloading the source code and compiling it again on the server, but I had the similar error again.
Cheers,
Abdullah
From the error, it seems that you did not set OCI_INCLUDE_DIR/OCI_LIB_DIR env variables
export OCI_HOME=<directory of Oracle instant client>
export OCI_LIB_DIR=$OCI_HOME
export OCI_INCLUDE_DIR=$OCI_HOME/sdk/include
export OCI_VERSION=<the instant client major version number> # Optional. Default is 11.
I had a same issue, except I am using ubuntu 10.04 and my installer miss the lnnz11 instead of locci. I set the environment variables, and the pre_install_check.sh reply me that "everything looks dandy", but it did not work.
After that I downloaded the instantclient version 11 instead of 12, and redefined the environment variables and it is working now.

Resources