大家好我正在尝试使用this教程为我的React Native应用创建忘记/重置密码服务。但是当我尝试启动服务器时,我收到有关路径的以下错误。
ReferenceError: path is not defined at Object.<anonymous> (/home/ubuntu/server/services/handlebars.js:16:15)
现在这是我的文件夹结构
-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
这是我的handlebars.js
var hbs = require('nodemailer-express-handlebars'),
email = process.env.MAILER_EMAIL_ID || 'email@gmail.com',
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));
答案 0 :(得分:0)
此处发生错误:
var handlebarsOptions = {
viewEngine: 'handlebars',
viewPath: path.resolve('../templates'),
extName: '.html'
};
require('path')
文件开头的handlebars.js
错综复杂:
var hbs = require('nodemailer-express-handlebars'),
email = process.env.MAILER_EMAIL_ID || 'email@gmail.com',
password = process.env.MAILER_PASSWORD || 'email_password'
nodemailer = require('nodemailer'),
path = require('path');