I'm trying to use an email template while sending emails. here's my project structure.
project-name
client
server
email-templates
confirm-email.html
controllers
accounts.js (currently here)
I am reading the template file like so.
fs.readFile('../email-templates/confirm-email.html', async (error, html) => {
// do some stuff
})
I think have entered a correct path. but still I get an error.
Error: ENOENT: no such file or directory
I have checked other questions on SO. but they are using the variable __dirname
because I am using ES6 modules I don't have access to that variable.
// package.json
"type": "module",
any suggestions ?