Error Running Test Script

Issue #13 new
Former user created an issue

I have gotten everything installed for Node and used npm to download the toolkit. I then created a script to test this code: // // Show how to connect to DB2 for i from Node.js //

var http = require('http') var db = require('/QOpenSys/QIBM/ProdData/Node/os400/db2i/lib/db2')

var server = http.createServer(function (req, res) { db.init() db.conn("*LOCAL") db.exec("SELECT LSTNAM, STATE FROM QIWS.QCUSTCDT", function(rs) { res.writeHead(200, {'Content-Type': 'text/plain'}) res.end(JSON.stringify(rs)) }) db.close() })

server.listen(8002) var host = server.address().address var port = server.address().port console.log('Example app listening at http://%s:%s', host, port)

and received the following errors: Error: 0509-022 Cannot load module /QOpenSys/QIBM/ProdData/Node/os400/db2i/bin/db2i.node. 0509-103 The module has an invalid magic number.
at Object.Module._extensions..node (module.js:681:18)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/QOpenSys/QIBM/ProdData/Node/os400/db2i/lib/db2.js:19:13)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)

Clearly we non-magical folks have no knowledge of a magic number. What's a muggle to do?

Comments (1)

  1. Aaron Bartell

    Looking at the below line of code tells us you're using the oldest version of Node.js that is no longer supported on IBM i.

    var http = require('http') var db = require('/QOpenSys/QIBM/ProdData/Node/os400/db2i/lib/db2')
    

    You'll want to install the latest version using:

    yum install nodejs10
    
  2. Log in to comment