Skip to content

Issue with express-handlebars (Error: ENOENT: no such file or directory, open '..\views\layouts\main.handlebars') #105

@jeanmichelmorin

Description

@jeanmichelmorin

I get this error:
Error: ENOENT: no such file or directory, open '..\views\layouts\main.handlebars'

Whenever I add this code:

const express = require('express');
const handlebars = require('express-handlebars');
const path = require('path');

const app = express();
const hbs = handlebars.create();

app.engine('hbs', hbs.engine);
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'hbs');

app.get('/', (req, res) => {
  res.render('main', {
    title: 'Hey There, World!',
    message: 'This is a fantastic example of Handlebars!'
  });
});

app.listen(3037);

This is from chapter 4.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions