gpt4 book ai didi

node.js - nodemailer Node 电子邮件模板,没有此类文件或目录错误

转载 作者:太空宇宙 更新时间:2023-11-03 22:02:53 25 4
gpt4 key购买 nike

我想使用email-templates package与 Nodemailer 结合使用,但收到有关模板文件不存在的错误。我已经尝试过绝对路径和相对路径,但均无济于事。最后我决定尝试让这个例子运行起来,但仍然没有运气。这是我所做的:

下载并解压 node-email-templates-master 的 zip 文件和:

cd node-email-templates-master

npm install

npm install nodemailer@0.3.27

cd examples/nodemailer

node index

我遇到了与以前相同的错误:

fs.js:338
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT, no such file or directory '../header/html.ejs'
at Object.fs.openSync (fs.js:338:18)
at fs.readFileSync (fs.js:182:15)
at Object.exports.parse (/mypath/node-email-templates-master/node_modules/ejs/lib/ejs.js:159:19)
at exports.compile (/mypath/node-email-templates-master/node_modules/ejs/lib/ejs.js:222:15)
at Object.exports.render (/mypath/node-email-templates-master/node_modules/ejs/lib/ejs.js:273:10)
at EmailTemplate.render (/mypath/node-email-templates-master/lib/main.js:63:16)
at Render.batch (/mypath/node-email-templates-master/examples/nodemailer/index.js:118:9)
at /mypath/node-email-templates-master/examples/nodemailer/index.js:126:16
at fs.stat.batchCheck (/mypath/node-email-templates-master/lib/main.js:130:18)

我正在运行 Node 版本0.8.12

通过以下方式安装软件包:

npm install email-templates

并执行示例文件:

node node_modules/email-templates/examples/nodemailer/index

同样的错误。有谁可以帮助我建立并运行电子邮件模板吗? Tnx!

最佳答案

这是一个非常常见的错误,已经在 ejs#68 上提到过。 。有关更多信息,请参阅ejs#69中的相关讨论。 .

一种快速而肮脏的修复方法是将所有必需的代码放入一个文件中。所以里面templates/newsletter从主 html.ejs/text.ejs 文件内的页眉/页脚文件中复制内容并删除包含 <% include ... %> 的行

关于node.js - nodemailer Node 电子邮件模板,没有此类文件或目录错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13894446/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com