The code generated by default with express-generator is ES5 code, using var, require, module.exports, and so on:
- The first thing we need to do is convert this code to be ES6. To do this, let's first modify our app.js file. This is the original code of this file:
var createError = require('http-errors'); var express = require('express'); var path = require('path'); var cookieParser = require('cookie-parser'); var logger = require('morgan'); var indexRouter = require('./routes/index'); var usersRouter = require('./routes/users'); var app = express(); // view engine setup app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'jade'); app.use(logger('dev')); app.use(express.json()); app.use(express.urlencoded ...