Node JS Binding error when trying to use IBM_DB - node.js

I am getting the below error when trying to use IBM_DB for db2 access.
$ node nodetest.js
C:\Users\workspace\nodetest\node_modules\bindings\bindings.js:79
throw e
^
Error: Module version mismatch. Expected 47, got 46.
at Error (native)
at Object.Module._extensions..node (module.js:440:18)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at bindings (C:\Users\workspace\nodetest\node_modules\bindings\bindings.js:74:15)
at Object.<anonymous> (C:\Users\workspace\nodetest\node_modules\ibm_db\lib\odbc.js:27:31)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
Here is the code I'm using:
var http = require("http");
var ibmdb = require("ibm_db");
console.log("Test program to access DB2 sample database");
http.createServer(function (request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello World\n');
}).listen(8081);
console.log('Server running at 127.0.0.1:8081/');
Can someone please help me on this ?

I know this is a 1 year old question but I think it requires at least one correct explanation/answer for that question here, so that future readers might not get confused.
Error: Module version mismatch. Expected 47, got 46.
You will encounter with this error mostly on Windows platform, and this is actually not a bug or defect, this is simply because node-ibm_db does not support particular node version (which you are using for installing node-ibm_db on windows platform).
Reason: node-ibm_db provides pre-compiled node binaries within the module for particular main node-versions (like 4.x, 6.x etc),module do not compile at installing time (on windows only), it uses the pre-compiled binaries to installation and setup.
Hence if you use a latest major version of nodejs and specifically that,- which node-ibm_db is not supporting yet (or simply pre-compiled binaries are not available), you will get this error.

Related

Primordials is not defined

I'm trying to execute this code but I don't know why it shows error. I'm new at Nodejs, so i attach the code and ss of error please help how to fix this
var webshot = require('webshot');
var flatiron = require('flatiron');
var app = flatiron.app;
app.use(flatiron.plugins.http);
app.router.get('/getImage', function() {
var self = this;
var requestUrl = this.req.headers['head'];
console.log(requestUrl);
webshot(requestUrl, function(err, renderStream) {
renderStream.pipe(self.res);
});
});
app.start(3000,"IP Address");
console.log('Starting Node Server');
error =
Debugger attached.
Waiting for the debugger to disconnect...
fs.js:45
} = primordials;
^
ReferenceError: primordials is not defined
at fs.js:45:5
at req_ (c:\Users\HOME\Desktop\NodeScripts\node_modules\natives\index.js:143:24)
at Object.req [as require] (c:\Users\HOME\Desktop\NodeScripts\node_modules\natives\index.js:55:10)
at Object.<anonymous> (c:\Users\HOME\Desktop\NodeScripts\node_modules\graceful-fs\fs.js:1:37)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
Process exited with code 1
First note encountering this kind of issue is not common when using Node.js. The packages webshot and flatiron haven't been maintained for 5 years at the time of writing, which is the primary reason they're incompatible with the current version of Node.js.
Typically when this error is encountered, you either need to use different packages, or downgrade to an older version of Node.js. According to the comments here, you should be able to downgrade to Node.js v11, but I highly suggest exploring more recently maintained packages like capture-website and express in order to stick with the latest LTS version of Node.js.

Invalid ELF Header on Production Server

Does anyone know why this error is occurring only on the production server and not when I run it locally?
internal/modules/cjs/loader.js:815
return process.dlopen(module, path.toNamespacedPath(filename));
^
Error: /var/www/vhosts/user9568/**SITE_NAME**/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node: invalid ELF header
at Object.Module._extensions..node (internal/modules/cjs/loader.js:815:18)
at Module.load (internal/modules/cjs/loader.js:641:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Module.require (internal/modules/cjs/loader.js:681:19)
at Module.require (/usr/share/passenger/helper-scripts/node-loader.js:80:25)
at require (internal/modules/cjs/helpers.js:16:16)
at Object.<anonymous> (/var/www/vhosts/user9568/**SITE_NAME**/node_modules/bcrypt/bcrypt.js:6:16)
at Module._compile (internal/modules/cjs/loader.js:774:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
at Module.load (internal/modules/cjs/loader.js:641:32)
The live server uses Plesk. I would appreciate any suggestions.
Also, please note that * * SITE_NAME * * is the domain name of the site, I didn't want to include it in this post for obvious reasons.
Picture of Error
I found the answer because I installed bcrypt on a Windows machine, but the production server is running Linux meant that it didn’t have the correct files to work with.
I fixed it by installing bcrypt on a Linux machine and then uploading it to the hosting server.
Do you use Docker? If yes, this question on Stack Overflow may already give you the answer.
TLDR: The .dockerignore file should include your node_modules folder.

Use edge js on openshift

I'm trying to run C# on my OpenShift cartridge with Edge.js. It runs really good on my Windows PC and I would like to have it running on the cloud.
I'm guessing it runs on a Linux environment but I'm not shure.
At first I tried to make it work with my MSSQL DB and than move on to the C# assembly.
Nevertheless I'm doing the same steps as how I've got it to work on my Windows machine but I'm getting thesame errors over and over again.
I've added edge and edge-sql to my npm and my package.json.
Then I've make a simple count to my MSSQL DB.
When I'm running it locally it works great. Than I push it to OpenShift and I tail the application, because the front-end gives me an Error 503, and the next thing I know the following error makes me keepings my hands in my hair.
Error: The edge native module is not available at /var/lib/openshift/54d26260fcf
933d05e00021a/app-root/runtime/repo/node_modules/edge/build/Release/edge.node. Y
ou can use EDGE_NATIVE environment variable to provide alternate location of edg
e.node. If you need to build edge.node, follow build instructions for your platf
orm at https://github.com/tjanczuk/edge
at Object.<anonymous> (/var/lib/openshift/54d26260fcf933d05e00021a/app-root/
runtime/repo/node_modules/edge/lib/edge.js:33:11)
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)
at require (module.js:380:17)
at Object.<anonymous> (/var/lib/openshift/54d26260fcf933d05e00021a/app-root/
runtime/repo/server.js:5:12)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
DEBUG: Program node server.js exited with code 8
DEBUG: Starting child process with 'node server.js'
/var/lib/openshift/54d26260fcf933d05e00021a/app-root/runtime/repo/node_modules/e
dge/lib/edge.js:33
throw new Error('The edge native module is not available at ' + builtEdge
Could somebody help me to fix this error or maybe explain to me why it could / wont work?
If edge requires a native windows environment to run C#, then it will not work on OpenShift, which runs on Red Hat Linux.

Invalid Win32 application while using iisnode, nodejs and node-soap library

I'm having some issues setting up a Node.js/Node-soap service running on IIS 7, Windows Server 2008, with iisnode and node.js 0.10.20. This same setup, with the same code, is running on another server inhouse and works perfectly.
The problem is that the setup process wasn't documented, and the person that put it all up is not available to migrate it to the new server. And I have no prior knowledge in Node nor IISnode.
This is the error message that gets printed:
iisnode encountered an error when processing the request.
HRESULT: 0x2 HTTP status: 500 HTTP reason: Internal Server Error You
are receiving this HTTP 200 response because
system.webServer/iisnode/#devErrorsEnabled configuration setting is
'true'.
In addition to the log of stdout and stderr of the node.exe process,
consider using debugging and ETW traces to further diagnose the
problem.
The last 64k of the output generated by the node.exe process to stderr
is shown below:
Application has thrown an uncaught exception and is terminated: Error:
%1 is not a valid Win32 application.
\node_modules\soap\node_modules\node-expat\build\Release\node_expat.node
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (<Path to application>\node_modules\soap\node_modules\node-expat\lib\node-expat.js:4:13)
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)
I've added the following to my Node.js file:
Now what I have found online, tried but hasn't worked, is as follows:
From this Stack Overflow question I tried two things:
Added this part to my Node.js file.
<iisnode watchedFiles="*.js;node_modules\*;routes\*.js;views\*.jade" nodeProcessCommandLine="\program files\nodejs\node.exe"/>
Created a symbolic link:
mklink /D "C:\Program Files (x86)\nodejs" "C:\Program Files\nodejs"
Will update if I try something else.
All help would be appreciated.
UPDATE 1:
I've made sure that the Enable32-Bit Applications = False. is set in IIS, and repaired the VS 2010 x64 redist binary
This error message suggests the bitness of \node_modules\soap\node_modules\node-expat\build\Release\node_expat.node does not match the bitness of the IIS worker process (w3wp.exe). Since you appear to be running IIS with 64 bit worker processes (Enable 32-bit Applications == False), it may indicate that node_expat.node is a 32-bit binary?

Unable to load /nowjs/now.js

When I start the server, I get the following error
[Error: Unable to load shared library /home/boopathi/node_modules/now/node_modules/node- proxy/lib/node-proxy.node]
Error: Unable to load shared library /home/boopathi/node_modules/now/node_modules/node-proxy/lib/node-proxy.node
at Object..node (module.js:465:11)
at Module.load (module.js:353:31)
at Function._load (module.js:310:12)
at Module.require (module.js:359:17)
at require (module.js:370:17)
at Object.<anonymous> (/home/boopathi/node_modules/now/lib/proxy.js:10:13)
at Module._compile (module.js:434:26)
at Object..js (module.js:452:10)
at Module.load (module.js:353:31)
at Function._load (module.js:310:12)
When I make the node-proxy module manually, I get the following warning..
[2/2] cxx_link: build/Release/node-proxy_1.o -> build/Release/node-proxy.node
in yellow color...
Now I'm not able to load the /nowjs/now.js file
I tried --harmony_proxies .. but it did not help ..
This should help you find it out:
Fire up gdb node. Type break node.cc:1624, then type run yourscript.js. When gdb hits the breakpoint, use p/a dlerror() to obtain the address of the error. It should print something like $123 = 0xabcddefg. Now use x/s 0xabcddefg (insert the address you got from the last command) to see the error. Is the error helpful?
I encountered same problem with bcrypt and found it's because my node was 32bit and bcrypt was build as 64bit. After I build a 64bit node, all things work fine.
I´ve tried this solution without success.
I guess the team made NowJS need to fix it current support in all plataforms. I cannot run NowJS under either Mac and Windows.
There is no way to accomplish it. Maybe some further version allow me to play with NowJS, but NOW, I can´t do it.

Resources