My handlebars setup seems to be encountering an issue
const path = require('path')
const exphbs = require('express-handlebars')
const morgan = require('morgan');
const multer = require('multer');
const express = require('express');
const erroHandler = require('errorhandler')
const routes = require('../routes/index');
module.exports = app => {
app.set('port', process.env.PORT || 80)
app.set('views', path.join(__dirname, '../views'));
app.engine('.hbs', exphbs({
defaultLayout: 'main',
partialsDir: path.join(app.get('views'), 'partials' ),
layoutDir: path.join(app.get('views'), 'layouts'),
helpers: require('../helpers')
}))
app.set('view engine', '.hbs');
// middlewares
app.use(morgan('dev'));
app.use(multer({dest: path.join(__dirname, '../public/upload/temp')}).single('image'))
app.use(express.urlencoded({extended: false}));
app.use(express.json());
//routes
routes(app)
// static files
app.use('/public', express.static(path.join(__dirname, '../public')));
// errorhandlers
if ('development' === app.get('env')) {
app.use(erroHandler)
}
return app;
}
Despite following the correct directory structure, the error message I receive is:
Error: ENOENT: no such file or directory, open 'C:\Users\Diesan Romero\Desktop\redsocial\views\layouts\main.handlebars'
I've checked my directories multiple times, but can't seem to figure out what's causing this issue. https://i.sstatic.net/ApTyk.png