Wiki
Clone wikinodejs / environment
#Table Of Contents
#Summary This page will give ideas for how to best setup your Node.js environment. Note, you need to install the Node.js licensed program from IBM. It's free.
Shell
As you adopt languages like Node.js, Ruby, Python, etc on IBM i it would be good to get yourself into a better shell because you will be spending a lot of time there. IBM i comes with a few that will get you by but I'd highly recommend installing bash. You can get bash from YiPs or install PowerRuby.
SSH on i
A best practice is to use a shell client to log into your PASE shell session. Mac and Linux come with adequate terminal clients. For Windows you can check out putty.
To connect to PASE on IBM i via SSH you first need to start the SSH daemon using the following command:
STRTCPSVR SERVER(*SSHD)
Then you can use your SSH client to make a connection, as shown below.
Setting PATH
and LIBPATH
You could type out the full path to the node
binary (i.e. /QOpenSys/QIBM/ProdData/Node/bin/node) or you can add it to the PATH
environment variable. The PATH
environment variable is like a library list that is used to resolve resources - basically a list of folders to search for things like binary files.
NOTE: Pete Helgren, IBM i open source pro, has gone deeper than this tutorial if you want more explanation.
export PATH=/QOpenSys/QIBM/ProdData/Node/bin:$PATH export LIBPATH=/QOpenSys/QIBM/ProdData/Node/bin:$LIBPATH
Now type node -v
and you should see something similar to the following:
$ node -v v0.10.29
/home/aaron/node_env.sh
. Then from the shell session invoke it as follows so it alters your current process (aka IBM i job). Note the period (.
) and space before specifying the call to node_env.sh. This is what causes the export
commands to be invoked in your current process.
If using bash
$ . ~/node_env.sh
$ . /home/aaron/node_env.sh
Web Server
If you desire something to front your Node.js app server you can opt for either Apache (IBM i's version) or nginx (ported by perzl.org). Some say it isn't necessary to run a web server in front of Nodejs - even for serving static files. Some use web servers (like Apache or nginx) to do load balancing between machines. This isn't common practice on IBM i because the machine can scale within itself which is one less reason to have Apache or nginx.
Editing Code
There are many ways to edit code on IBM i. Here are some common ones:
- RDi (purchaseable from IBM)
- RPGNextGen Editor (free and open source)
- joe editor (included with PowerRuby download) (i.e.
$ joe /path/to/pgm.js
) - Map a drive
- EDTF (i.e. from 5250:
EDTF '/path/to/pgm.js'
- others? Add your preference.
Updated