【发布时间】:2021-08-14 11:44:16
【问题描述】:
我在发送电子邮件时尝试使用电子邮件模板。这是我的项目结构。
project-name
client
server
email-templates
confirm-email.html
controllers
accounts.js (currently here)
我正在像这样读取模板文件。
fs.readFile('../email-templates/confirm-email.html', async (error, html) => {
// do some stuff
})
我认为已经进入了正确的道路。但我仍然收到错误。
错误:ENOENT:没有这样的文件或目录
我已经检查了关于 SO 的其他问题。但他们正在使用变量 __dirname,因为我使用的是 ES6 模块,我无权访问该变量。
// package.json
"type": "module",
有什么建议吗?
【问题讨论】: