Hey everyone, I'm currently working on implementing a forgot/reset password feature for my React Native app using this tutorial. However, when attempting to start the server, I encountered an error related to the 'path'.
ReferenceError: path is not defined at Object.<anonymous> (/home/ubuntu/server/services/handlebars.js:16:15)
Let me show you my folder structure:
-server
-controllers
authentication_controller.js
-models
user.js
-services
handlebars.js
passport.js
router.js
-templates
forgot-password-email-template.html
reset-password-email-template.html
index.js
Below is the content of my handlebars.js file:
var hbs = require('nodemailer-express-handlebars'),
email = process.env.MAILER_EMAIL_ID || '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="cfaaa2aea6a38fa8a2aea6a3e1aca0a2">[email protected]</a>',
password = process.env.MAILER_PASSWORD || 'email_password'
nodemailer = require('nodemailer');
var smtpTransport = nodemailer.createTransport({
service: process.env.MAILER_SERVICE_PROVIDER || 'Gmail',
auth: {
user: email,
password: password
}
});
var handlebarsOptions = {
viewEngine: 'handlebars',
viewPath: path.resolve('../templates'),
extName: '.html'
};
smtpTransport.use('compile', hbs(handlebarsOptions));