I know nothing about the libraries you're trying to use so I'm not sure how much help the following will be, but I did have a quick look out of curiosity. The itoolkit has a dependency in istoredp.js on "idb-connector", this isn't included in the itoolkit's package's dependencies so it has to be installed separately with "npm i idb-connector", the problem is that this package has dependencies on binary objects which appear to be platform specific to the IBM i, meaning you cannot use this library on a platform other than the IBM i.

Your frustrations are along the lines of what I mentioned way back in one of the other threads somewhere about a lack of decent DB2 (or any other) database drivers for NodeJs. In Java, if you want to access a database, you get yourself a JDBC driver and away you go, you can point it at the local or a remote database seamlessly (so you can do what you're asking and run an app on a PC server to connect to a database on the IBM i). Often the JDBC drivers come in two flavours, one native and one "pure Java" (called a type-4 driver), this means you can in theory switch in the faster driver when you are running Java on the same platform where the database resides. As far as I can tell, this whole concept is missing from node.

If you just want to access the database then I believe this package will allow you to reach across from your PC to the IBM i https://www.npmjs.com/package/ibm_db but as for executing commands and accessing native objects I don't know, I've never really looked into it.





________________________________
From: WEB400 <web400-bounces@xxxxxxxxxxxx> on behalf of Kelly Cookson <KCookson@xxxxxxxxxxxx>
Sent: 22 March 2018 04:57
To: Web Enabling the IBM i (AS/400 and iSeries)
Subject: [WEB400] Problem with iToolkit in Node on Windows

I installed Node on my Windows 7 laptop.

I went to the npm site (https://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2Fitoolkit&data=02%7C01%7C%7C033d1e68855b412f855808d58fa92a1f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636572879070409152&sdata=N4DzS260jiJn3uNE0oG%2B9UEWkLbO89Dr6U878mhlmnY%3D&reserved=0) and installed iToolkit using the command: node i itoolkit

I wrote a small script named helloIBMi.js shown here:
const xt = require('itoolkit');
var conn = new xt.iConn('mysystem', 'myname', 'mypwd');
conn.debug(true);
console.log('Current XML Service Library is : ');
console.log(conn.getConnection().I_XML_SERVICE_LIB);
console.log('end script');

This script worked. It made the connection and returned the service library name:
node helloIBMi
Current XML Service Library is :
QXMLSERV
end script

I then tried to add a command from example on the API page (https://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.ibm.com%2Fdeveloperworks%2Fcommunity%2Fwikis%2Fhome%3Flang%3Den%23!%2Fwiki%2FIBM%2520i%2520Technology%2520Updates%2Fpage%2FToolkit%2520for%2520i%2520APIs%3Fsection%3DiSh&data=02%7C01%7C%7C033d1e68855b412f855808d58fa92a1f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636572879070409152&sdata=Y8zDfokMJLH7mCvcujqLXYh6rxBZ%2BJ4jYA%2FgfFhGr88%3D&reserved=0). I tried to delete a file in the IFS using the iCmd class:
const xt = require('itoolkit');
var conn = new xt.iConn('mysystem', 'myname', 'mypwd');
conn.debug(true);
console.log('Current XML Service Library is : ');
console.log(conn.getConnection().I_XML_SERVICE_LIB);
conn.add(xt.iCmd("RMVLNK OBJLNK('/mydir/nodetest.txt')"));
function cb(str) {console.log(str);}
conn.run(cb);
console.log('end script');

This fails. The “conn.run(cb)” line is what throws the errors. The errors I get in the console are:
node helloIBMi
Current XML Service Library is :
QXMLSERV
============
INPUT XML
============
<?xml version='1.0'?><myscript><cmd exec='cmd' error='fast'>RMVLNK OBJLNK('/mydir/nodetest.txt')</cmd></myscript>
============
OUTPUT XML
============
{ Error: Cannot find module 'idb-connector'
at Function.Module._resolveFilename (module.js:538:15)
at Function.Module._load (module.js:468:25)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at Object.db2Call (C:\mydirectorypath\node_modules\itoolkit\lib\istoredp.js:89:14)
at iConn.run (C:\mydirectorypath\node_modules\itoolkit\lib\itoolkit.js:278:10)
at Object.<anonymous> (C:\mydirectorypath\helloIBMi.js:11:6)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32) code: 'MODULE_NOT_FOUND' }
end script

I confirmed that all of the iToolkit *.js files are installed in the C:\mydirectorypath\node_modules\itoolkit\lib\ directory. The same *.js files are in my laptop directory as are in the IFS directory /QOpenSys/QIBM/ProdData/Node/os400/xstoolkit.

Any ideas? I can’t find a lot of documentation online to help me, and I’m also still pretty new.

Thanks,

Kelly Cookson
IT Project Leader
Dot Foods, Inc.
217-773-4486 ext. 12676
https://nam03.safelinks.protection.outlook.com/?url=www.dotfoods.com&data=02%7C01%7C%7C033d1e68855b412f855808d58fa92a1f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636572879070409152&sdata=rIidXxYoSe7LJRBallD73ofEXIgXRRTGT2LCS9zI%2Bhc%3D&reserved=0<https://nam03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.dotfoods.com&data=02%7C01%7C%7C033d1e68855b412f855808d58fa92a1f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636572879070409152&sdata=dyeRlYwpwQyGeHjexjxtV4fQyqmxdjKECre7oceECeg%3D&reserved=0>

--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing list
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.midrange.com%2Fmailman%2Flistinfo%2Fweb400&data=02%7C01%7C%7C033d1e68855b412f855808d58fa92a1f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636572879070409152&sdata=U%2BRcDA2tijA%2B%2BPUzzoo%2BD7Xa5TJPWTXQPZ%2Fcy3Wy%2F10%3D&reserved=0
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Farchive.midrange.com%2Fweb400&data=02%7C01%7C%7C033d1e68855b412f855808d58fa92a1f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636572879070409152&sdata=6kKOXYn%2Bq74qPfcxE3bn9f9RgIXpst6RdsEaNb3vM2Q%3D&reserved=0.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.