Errata

Web Development with Node and Express

Errata for Web Development with Node and Express, Second Edition

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted By Date submitted Date corrected
Ch 7
Chapter 7, 3rd code example under "Sections" header

While reading this book via Safari Books Online (macOS Chrome 80.x), I noticed that a code example in Chapter 7 is incorrect. This is the third code example under the "Sections" header prefaced with the sentence "Now in our layout, we can place the sections just as we place {{{body}}}:".

Looking at the GitHub repo of code examples, the GitHub code example is correct, but the one in book is not. The code on GitHub should be the code included in the book. Please see: https://github.com/EthanRBrown/web-development-with-node-and-express-2e/blob/master/ch07/views/layouts/main.handlebars

Enjoying the book. Thank you.

Note from the Author or Editor:
Oh wow, good catch...this has been corrected.

Anonymous  Apr 22, 2020 
Page page 27, Views and Layouts
2nd paragraph (The setup code for the meadowlark.js file)

The setup configuration of the meadowlark.js file to use handlebars didn't work for me. The configuration that works for me involves using the ES module by adding the type field with the module value to the package.json file. Then change the setup to:

import express from 'express';
import {engine} from 'express-handlebars';

const app = express();
const port = process.env.PORT || 3000;

// configure Handlebars view engine
app.engine('handlebars', engine());
app.set('view engine', 'handlebars');
app.set('views', './views');

//Thank you for this beautiful book. It's the best book I selected out of many //others.

Note from the Author or Editor:
express-handlebars has changed it's packaging, and the current version has a different import structure. The version in the companion repository (^3.0.2) works as written. I will revise the text accordingly.

Suraju Ogundele  Aug 13, 2023 
Printed
Page 81
top of page Note

The text says one can change the "handlebars" extension to ".hbs" by passing an object "{extname: '.hbs'}" when creating the express-handlebars instance. This did not work for me.

The express-handlebars docs have an example:

app.engine('.hbs', exphbs({
extname:'.hbs',
defaultLayout: 'home',
helpers: {
section: function(name, options) {
if(!this._sections) this._sections = {}
this._sections[name] = options.fn(this)
return null
},
},
}));
app.set('view engine', '.hbs');

which does work.

Note from the Author or Editor:
This has been corrected.

Beardsley Ruml  May 15, 2020