Node, The First Kiss

Gimme sugar, baby! You may have heard about Node.js, a recently released platform that’s a means to write Web applications using JavaScript on the server. When I’m learning about a new technology, I always like to get something working in as short a time as possible, so let’s do that with this article and subsequently dive into details.

First, head to the IBM i Node.js developerWorks site to learn now to install the free IBM licensed program 5733OPS. Not an option to install Node.js on your IBM i? Check out for now.

Once the install of 5733OPS is complete, you can run the following commands in PASE to set up your environment. Setting these variables lets you invoke Node.js from any directory while in PASE. To run the commands in PASE you can either CALL QP2TERM from the 5250 command line or SSH into your machine using a terminal client (I like this Chrome plugin). If you’d like more info on SSH config for your IBM i then please check out this page I’ve set up.

$ export PATH=/QOpenSys/QIBM/ProdData/Node/bin:$PATH
$ export LIBPATH=/QOpenSys/QIBM/ProdData/Node/bin:$LIBPATH

This is similar to how a library list works: The PATH environment variable declares what directories should be searched when commands are run. Similarly the LIBPATH environment variable declares where to look for shared libraries that the node binary requires. Note a “shared library” is completely different than a QSYS.LIB library.

Now we can test to see if we have access to the node binary by typing the node -v command, as shown:

$ node -v

Success! Next simply type “node” at the command prompt to start up what’s called the Node.js REPL. The Node.js REPL is an interactive environment that lets you enter Node.js statements for immediate invocation. Figure 1 is a screenshot of an SSH session into my IBM i using the Chrome plugin I mentioned. The first thing you see is the addition of 2 + 2, which results in, obviously, 4. This is REPL in action—read, evaluate, print and loop. Most anything you’d write in a Node.js program can be placed into the REPL. I’ve become a big fan of REPLs (Ruby has one also) for the purposes of not only learning a new technology but also as a means to quickly test code. To return to your PASE shell, type .exit.

Aaron Bartell is Director of IBM i Innovation for Krengel Technology Inc. and an IBM Champion.

Like what you just read? To receive technical tips and articles directly in your inbox twice per month, sign up for the EXTRA e-newsletter here.

comments powered by Disqus



2019 Solutions Edition

A Comprehensive Online Buyer's Guide to Solutions, Services and Education.

Are You Multilingual?

Rational enables development in multiplatform environments

IBM Systems Magazine Subscribe Box Read Now Link Subscribe Now Link iPad App Google Play Store
IBMi News Sign Up Today! Past News Letters