Question
· 4 hr ago

NodeJS Iris Package - Work on node Windows?

Hello, Does the NodeJs package work when running a node js file on windows (nodejs for windows)? I've added the package by running npm install <package location folder>

 

I have the following index.js file, but when running from node (windows) I get the following error. Does the NodeJs package build the output files when the package is added or does it just assume linux as the underlying os?

Error: Cannot find module './bin/winx64/irisnative.node'

 const IRISNative = require('intersystems-iris-native')

  let connectionInfo = {
    host: 'myserver',
    port: 1972,
    ns: 'USER',
    user: 'user',
    pwd: 'password',
    sharedmemory: true,
    timeout: 5,
    logfile: '.\\mylogfile.log'
  };

  const conn = IRISNative.createConnection(connectionInfo);
Product version: IRIS 2024.3
Discussion (2)2
Log in or sign up to continue

The support for NodeJS in IRIS is quite primitive and limited to only native functions, globals, methods, no SQL

check in IRIS folder, what do you have installed with IRIS for nodejs

I don't have windows, only docker, and in my case

/usr/irissys/bin/iris1200.node
/usr/irissys/bin/iris800.node
/usr/irissys/bin/iris1600.node
/usr/irissys/bin/iris1400.node
/usr/irissys/bin/iris1000.node
/usr/irissys/dev/nodejs/intersystems-iris-native/bin/lnxubuntuarm64/irisnative.node

If you want to use IRIS SQL from nodejs, you can try my package, which you can install with npm

npm install intersystems-iris
const { IRIS } = require("intersystems-iris");

async function main() {
    const db = new IRIS('localhost', 1972, 'USER', '_SYSTEM', 'SYS')
    console.log('connected')
    let res = await db.sql("select 1 one, 2 two")
    console.log(res.rows);
    await db.close()
}

main()

It's quite simple at the moment, only supports SQL with no parameters, but should work I believe

For high performance and full functionality, you should use mg-dbx-napi instead:

https://github.com/chrisemunt/mg-dbx-napi

Best to use it in conjunction with QOper8 to create a scalable, multi-user architecture:

https://github.com/robtweed/qoper8-cp

Typically you'll use QOper8 with a JS Web framework such as Fastify, in which case also look at QOper8-Fastify which adds routing capabilities that integrate automatically with QOper8 workers:

https://github.com/robtweed/qoper8-fastify

or for even better performance use Bun's Bun.serve instead along with our mg-bun-router:

https://github.com/robtweed/mg-bun-router

Another alternative is to use our mg-web add-on for NGINX, Apache or IIS and its Javascript server plug-in:

https://github.com/chrisemunt/mg_web

https://github.com/chrisemunt/mg_web_js

together with our router:

https://github.com/robtweed/mg_web_router

So quite a range of technologies and options for working with Node.js and Bun.  If you want to learn more about how to use these technologies with IRIS, I'd recommend taking a look at our mg-showcase repository:

https://github.com/robtweed/mg-showcase