nodemailer node-email-templates,没有这样的文件或目录错误

我想使用电子邮件模板软件包与nodemailer结合使用,但是得到关于模板文件不存在的错误。 我已经尝试了绝对的相对path,都无济于事。 最后,我决定尝试让示例工作,但仍然没有运气。 这是我做的:

下载并解压缩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) 

我正在运行节点版本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 ... %>

Windows不支持更长的path,有时这no such file or directory导致no such file or directory错误。 把你的项目放在根目录下,说'C:\ Project',然后尝试执行你的程序。

由于漫长的path等级,我以前也遇到类似的错误。