Create HTTP errors for Express, Koa, Connect, etc. with ease. Install This is a Node.js module available through the npm registry. Installation is done using the npm install command: var createError = require('http-errors') var express = require('express') var app = express() app.use(function (req, res, next) { if (!req.user) return next(createError(401, 'Please login to view this page.')) next()