July 2017
Intermediate to advanced
656 pages
16h 1m
English
Let's copy the application we created in the Creating a Koa web app recipe, and call it koa-views.
We'll install the ejs and koa-views modules:
$ cp -fr creating-a-koa-web-app/app koa-views $ cd koa-views $ npm install --save koa-views ejs
We'll also copy the views folder from the main recipe to the koa-views/views:
$ cp -fr ../express-views/views views
Next we'll require the koa-views module among the other dependencies at the top of index.js:
const {join} = require('path')
const Koa = require('koa')
const serve = require('koa-static')
const views = require('koa-views')
const router = require('koa-router')()
const index = require('./routes/index')
Next just beneath where we assign the port constant in index.js ...