Chapter 3: Installing Node.js on IBM i
The dust is settling, but we are still a way from the finish line.
Let's start by double checking our install to see which versions of Node.js are available
You'll see packages like nodejs18, nodejs20, nodejs22 (the list grows as new LTS releases arrive). Always pick an LTS (Long Term Support) version - even numbers. In this course I use nodejs24; if nodejsXX (newer) is available on your box, feel free to use that instead - the code in this course works the same.
Assumption you installed Nodejs24
Say y when prompted. It installs under /QOpenSys/pkgs/lib/nodejs24/.
Make it the default "node"
Because multiple Node versions can live side by side, IBM provides a little helper called nodever to choose which one node and npm point at:
nodever 24
nodever updates the symlinks in /QOpenSys/pkgs/bin so node and npm resolve to Node 24. (Want it only for your own session? nodever 24 --user instead. Run nodever --help for the options on your installed version.)
Verify the install
npm --version
node -e "console.log('Hello from', process.platform, process.arch)"
Expected output (version numbers will vary):
10.x.x
Hello from aix ppc64
Yes, aix - that's PASE telling the truth about its heritage. Don't panic.
Your first program
cat > hello.js <<'EOF'
const http = require('http');
const server = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello from Node.js on IBM i!\n');
});
server.listen(3000, () => console.log('Listening on port 3000'));
EOF
node hello.js
Point your browser at http://myibmi:3000 and bask in the glory. Ctrl+C to stop.
Firewall note: If the browser can't connect, your network team may need to open port 3000 to the IBM i.
Updating later
yum upgrade nodejs20Keeping the runtime patched is a security must, just like PTFs.
