2012-12-15 35 views
2

我想使用email-templates package與nodemailer結合使用,但是我得到的模板文件不存在錯誤。我已經嘗試了絕對的相對路徑,都無濟於事。最後,我決定嘗試讓示例工作,但仍然沒有運氣。下面是我做的:nodemailer node-email-templates,沒有這樣的文件或目錄錯誤

下載和提取的node-email-templates-master zip文件和:

我收到同樣的錯誤作爲前:

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!

回答

1

這是一個很常見的錯誤,已在ejs#68上提及。欲瞭解更多信息,請參閱ejs#69中的相關討論。

一個快速和髒的修復將把所有需要的代碼放入一個文件。所以裏面templates/newsletter複製從主html.ejs/text.ejs文件中的頁眉/頁腳文件的內容,並刪除含有<% include ... %>

1

行Windows不支持更長的路徑,有時這會導致no such file or directory錯誤。把你的項目放在根的某個地方,比如'C:\ Project',然後嘗試執行你的程序。

由於長路徑層次結構,我以前遇到過類似的錯誤。

+0

我沒有使用Windows,所以這不可能是問題 – DivZero

相關問題