Error: A partials dir must be a string or config object in handlebars Error: A partials dir must be a string or config object in handlebars express express

Error: A partials dir must be a string or config object in handlebars


Looks like a recent change to express-handlebars caused this issue, someone posted a fix here https://github.com/yads/nodemailer-express-handlebars/issues/22

Or

I guess you could just go back to a version that doesn't have this issue, at least until it is fixed.


I managed to get my code working, posting in case it helps out. I had to add the partialsDir to my handlebarOptions where I didn't have the field before:

const handlebarOptions = {  viewEngine: {    extName: '.hbs',    partialsDir: 'src/path',    layoutsDir: 'src/path',    defaultLayout: 'email.hbs',  },  viewPath: 'src/path',  extName: '.hbs',};transporter.use('compile', hbs(handlebarOptions));

Hope this helps.