The Node.js ecosystem
Earlier we built a small Express server by hand, and that then grew that into a real app. That's the right way to learn - you know what every line is for.
Sometimes, though, you just want a skeleton: folders for routes, views, static files, and a package.json with the right bits already wired up. That's what Express Generator does. It's a command-line tool that writes a starter Express application for you in a few seconds.
An honest note before we start
The package is called express-generator. You run it with npx, which comes with npm (and therefore with nodejs24). You do not need to install it globally:
bash
A few facts worth knowing, because the internet is full of older instructions:
If you want a modern Express 5 app, the course way is still the best one: npm init -y, npm install express, and write it yourself the way we did in Section 4. Treat the generator as a shortcut for a classic Express 4 site, not as a requirement.
Generate a skeleton
Pick a folder in the IFS - I'll use your home directory - and ask the generator for EJS views (-e or --view=ejs). EJS is plain HTML with a few <%= %> markers, which is a gentle start if you've never used a template engine.
bash
npx express-generator --view=ejs demoApp
cd demoApp
npm install
You'll see it create a handful of files and folders. Then npm install reads the generated package.json and fetches the dependencies (Express, EJS, and a few middleware packages such as morgan for request logging and cookie-parser).
Have a look at that package.json. The generator still pins Express 4.16-era versions (for example express: ~4.16.1). That's fine for a skeleton, and it will run. If you're starting a real project from it, bump those ranges to current Express 4 releases (or move to Express 5 and adjust the code) before you go much further.
What's in the box
That's one of many possible layouts, not a law of physics. The idea is:
Have a poke around. `routes/index.js` is only a few lines:
var router = express.Router();
router.get('/', function (req, res, next) {
res.render('index', { title: 'Express' });
});
module.exports = router;
Yes, you are right! The generator still writes var. You can change it to const if it offends you. It will not offend the code 🙂
Run it on IBM i
bash
Or, to see the debug output the generator wired up (this is bash, so it works in our SSH session). Note the lowercase demoapp - the generator lowercases the folder name when it sets up the debug namespace:
bash
Then, from your PC's browser: http://myibmi:3000/
You should get a page that says "Express" and "Welcome to Express." The /users route is a plain-text stub. Ctrl+C in the terminal stops the server, same as always.
Port already in use? If the ingredients app from Section 5 is still running on 3000 (perhaps under PM2), either stop it (pm2 stop ingredients-app) or start this one on another port: PORT=3001 npm start
Where you'd take it next
This skeleton is a starting point, not a finished application. To make it talk to IBM i you'd do the same things we already did by hand:
For an API-only service, you may not want views at all:
bash
That skips the template engine and gives you a slimmer skeleton.
So: the generator is a fast way to get a traditional Express folder tree. You already know how to do the interesting part - the routes, the SQL, the RPG calls - without it. Use whichever starting point makes you faster.

