To tell handlebars where the views are you can configure it like this
app.set('view engine', 'hbs');
app.set('views', path.join(__dirname, '../../src/server/views'));
app.engine('hbs', exphbs({
defaultLayout: 'index',
extname: 'hbs',
layoutsDir: path.join(__dirname, '../../src/server/views/layouts'),
partialsDir: path.join(__dirname, '../../src/server/views'),
}));
So it will look for views in the src
folder.
Another option is to use ts-node
instead of node
. With it you don't need to compile your project and you don't need a dist folder, and you can configure it to look directly from where you are:
app.set('view engine', 'hbs');
app.set('views', path.join(__dirname, 'views'));
app.engine('hbs', exphbs({
defaultLayout: 'index',
extname: 'hbs',
layoutsDir: path.join(__dirname, 'views/layouts'),
partialsDir: path.join(__dirname, 'views'),
}));
If you want to copy the views to the dist folder you could: