Lesson 4 · Node.js on IBM i — From RPG Developer to Modern IBM i Developer
Your First Node.js Program on IBM i
Create a small JavaScript file in the IFS, run it with Node.js, and understand each part without a JavaScript crash course.
Your first Node.js program needs only one JavaScript file and the node command. No framework, web server, or database connection is required yet.
For this lesson, there are only three steps:
Create a file in the IFS
↓
Run it with Node.js
↓
See the result in your terminal
Create a project directory
Connect to IBM i through SSH and work from your home directory:
cd "$HOME"
mkdir -p eraofi-node
cd eraofi-node
pwd
The pwd command should show the IFS directory you created.
Use an IFS-aware editor, VS Code with an IBM i connection, or another text editor in your normal development workflow to create a file named hello.js in that directory.
Write the program
Add this code to hello.js:
const developer = 'RPG developer';
const platform = 'IBM i';
console.log(`Hello, ${developer}.`);
console.log(`Node.js is running on ${platform}.`);
Save the file, then run it:
node hello.js
You should see:
Hello, RPG developer.
Node.js is running on IBM i.
The shell found the Node.js executable through PATH. Node.js then read the JavaScript stream file from the IFS, executed it, and wrote the result to your terminal.
Read the code as an RPG developer
This line declares a value that will not be reassigned:
const developer = 'RPG developer';
You can think of const as saying, “this name should continue to refer to this value.” It is not exactly the same as an RPG named constant, but it communicates similar intent in this example.
This line writes to standard output:
console.log(`Hello, ${developer}.`);
The backticks create a template string. ${developer} inserts the value into the text.
You do not need to learn all of JavaScript syntax at once. For this lesson, the important ideas are:
- A Node.js source file normally ends in
.js. - Statements run from top to bottom.
constdeclares a name.console.log()writes output.node filename.jsruns the program.
Make one practical change
Add a small function below the existing lines:
function buildStatus(runtime, platform) {
return `${runtime} is ready on ${platform}.`;
}
const status = buildStatus('Node.js', 'IBM i');
console.log(status);
Run the program again:
node hello.js
The new output includes:
Node.js is ready on IBM i.
An RPG procedure and a JavaScript function serve a similar high-level purpose: they give a piece of logic a name, accept inputs, and can return a result.
If the program does not run
Running from the wrong directory
If Node.js reports that it cannot find the module or file, use pwd and ls to confirm you are in the directory containing hello.js.
Case differences
IFS file names can be case-sensitive. hello.js and Hello.js may not refer to the same file.
Source encoding
Keep Node.js source as a Unicode stream file, normally UTF-8. Be deliberate about editor and file CCSID settings when moving source between traditional IBM i tools and the IFS.
Starting with a framework
Frameworks are useful later, but they can hide the fundamentals. First become comfortable running a plain Node.js file.
What you accomplished
You have now run JavaScript directly on IBM i:
node hello.js
The program lives in the IFS and runs in PASE, but it is still operating on the same IBM i system as your RPG applications.
In the next lesson, we will turn this directory into a managed Node.js project using npm and package.json.
References
Documentation and references used for this lesson.

Comments
Share your thoughts, questions, or real-world IBM i experiences related to this article.