NodeJS Express Create Project

If you haven’t installed NodeJS on your local, you need to install it before creating an express project:

mkdir myexpress
cd myexpress
npx express-generator
npm install
DEBUG=myexpress:* npm start

By default the web project is running at the following location: http://localhost:3000/

Let’s test by adding a greeting route.

var express = require('express');
var router = express.Router();

/* GET home page. */
router.get('/', function(req, res, next) {
  res.render('index', { title: 'Express' });

router.get('/hello', function(req, res, next) {
  greeting = 'Hello ' +;
  res.render('index', { title: greeting});

module.exports = router;

Restart server for testing:

DEBUG=myexpress:* npm start
Add to my src(0)

No account yet? Register