nodemailer node-email-templates, no such file or directory errors

I want to use email-templates package in combination with nodemailer, but am getting errors about the template files not existing. I have tried both absolute as relative paths, all to no avail. Finally I decided to try and get the example to work, but still no luck. Here is what I did:

Download and extract zip file of node-email-templates-master and:

cd node-email-templates-master

npm install

npm install nodemailer@0.3.27

cd examples/nodemailer

node index

I am getting the same errors as before:

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)

I am running node version 0.8.12

Installing the package via:

npm install email-templates

and executing the example file:

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

Give the same error. Is there anyone who can please help me get email-templates up and running? Tnx!

This is a quite common error and already mentioned on ejs#68. For more information see the related discussion in ejs#69.

A quick and dirty fix would be putting all the required code inside one file. So inside the templates/newsletter copy the content from the header/footer files inside the main html.ejs/text.ejs file and delete the lines containing <% include ... %>

Windows does not support longer paths and sometimes this causes no such file or directory errors. Place your project somewhere in the root, say 'C:\Project' and then try to execute your program.

I've faced similar errors in the past due to long path hierarchy.